Actualizar sigpro_work.js

This commit is contained in:
2026-04-07 19:06:09 +02:00
parent 7400d64f5a
commit f394a4720e

View File

@@ -370,14 +370,28 @@ const Router = (routes) => {
return rp.length === pp.length && rp.every((x, i) => x.startsWith(":") || x === pp[i]); return rp.length === pp.length && rp.every((x, i) => x.startsWith(":") || x === pp[i]);
}) || routes.find(r => r.path === "*"); }) || routes.find(r => r.path === "*");
if (route) { 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(); if (view) view.destroy();
view = Render(() => route.component()); view = Render(() => route.component(params));
outlet.appendChild(view.container); outlet.appendChild(view.container);
} }
}); });
return outlet; 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 Mount = (component, target) => {
const el = typeof target === "string" ? doc.querySelector(target) : target; const el = typeof target === "string" ? doc.querySelector(target) : target;
if (!el) return; if (!el) return;