From f394a4720eab30275d47a4da27f67bae512cbb75 Mon Sep 17 00:00:00 2001 From: natxocc Date: Tue, 7 Apr 2026 19:06:09 +0200 Subject: [PATCH] Actualizar sigpro_work.js --- sigpro_work.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sigpro_work.js b/sigpro_work.js index 031e967..df7c779 100644 --- a/sigpro_work.js +++ b/sigpro_work.js @@ -370,14 +370,28 @@ const Router = (routes) => { return rp.length === pp.length && rp.every((x, i) => x.startsWith(":") || x === pp[i]); }) || routes.find(r => r.path === "*"); if (route) { + const params = {}; + const rp = route.path.split("/").filter(Boolean); + const pp = p.split("/").filter(Boolean); + rp.forEach((part, i) => { + if (part.startsWith(":")) params[part.slice(1)] = pp[i]; + }); + + Router.params(params); + if (view) view.destroy(); - view = Render(() => route.component()); + view = Render(() => route.component(params)); outlet.appendChild(view.container); } }); return outlet; }; +Router.params = $({}); +Router.to = (p) => (window.location.hash = p.replace(/^#?\/?/, "#/")); +Router.back = () => window.history.back(); +Router.path = () => window.location.hash.replace(/^#/, "") || "/"; + const Mount = (component, target) => { const el = typeof target === "string" ? doc.querySelector(target) : target; if (!el) return;