diff --git a/hub/filelib-web/src/routes/database/dashboard/+layout.svelte b/hub/filelib-web/src/routes/database/dashboard/+layout.svelte index 655f099..a6f84e6 100644 --- a/hub/filelib-web/src/routes/database/dashboard/+layout.svelte +++ b/hub/filelib-web/src/routes/database/dashboard/+layout.svelte @@ -28,9 +28,18 @@ const BASE = "/database/dashboard"; - onMount(async () => { - await loadSession(); - if ($me === null) void goto("/database/admin", { replaceState: true }); + onMount(loadSession); + + /** + * 未登录一律回登录页 —— 必须是 effect 而非 onMount 里的一次性判断: + * `logout()` 只清 store(它被老师端 /app 共用,那边 me=null 是终态而非跳转), + * 退出后这层壳会重新渲染成 me===null,若跳转只写在 onMount 就永远停在 + * "跳转到登录页…"。 + */ + $effect(() => { + if ($authChecked && $me === null) { + void goto("/database/admin", { replaceState: true }); + } }); function href(seg: string): string {