Fix: Correction du routage et chargement initial des vues
All checks were successful
Deploy / Deploy to Production (push) Successful in 15s
All checks were successful
Deploy / Deploy to Production (push) Successful in 15s
Router: - Suppression de l'appel direct à loadPage au démarrage - router.listen() gère maintenant le chargement initial - Utilisation de router.run() dans le handler popstate - Résolution de la 404 sur /.json à la home App.svelte: - Attente de pageData avant calcul du template et de la vue - Renommage de view en View (majuscule requise en Svelte 5) - Correction de la réactivité des composants dynamiques Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9ab6344835
commit
65cfba8c77
2 changed files with 6 additions and 9 deletions
|
|
@ -29,10 +29,10 @@
|
|||
'default': Default
|
||||
}
|
||||
|
||||
const template = $derived(page.template || 'default')
|
||||
const view = $derived(templates[template] || Default)
|
||||
const pageData = $derived(page.data)
|
||||
const showFooter = $derived(template !== 'home')
|
||||
const template = $derived(pageData ? (page.template || 'default') : null)
|
||||
const View = $derived(template ? (templates[template] || Default) : null)
|
||||
const showFooter = $derived(template && template !== 'home')
|
||||
</script>
|
||||
|
||||
<div class="app">
|
||||
|
|
@ -40,8 +40,8 @@
|
|||
<Header />
|
||||
|
||||
<main class="main">
|
||||
{#if pageData && view}
|
||||
<view data={pageData} />
|
||||
{#if pageData && View}
|
||||
<View data={pageData} />
|
||||
{/if}
|
||||
</main>
|
||||
|
||||
|
|
|
|||
|
|
@ -60,9 +60,6 @@ router
|
|||
});
|
||||
|
||||
export function initRouter() {
|
||||
// Load initial page data
|
||||
loadPage(window.location.pathname);
|
||||
|
||||
// Start listening to route changes
|
||||
router.listen();
|
||||
|
||||
|
|
@ -86,7 +83,7 @@ export function initRouter() {
|
|||
|
||||
// Handle browser back/forward
|
||||
window.addEventListener("popstate", () => {
|
||||
loadPage(window.location.pathname);
|
||||
router.run(window.location.pathname);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue