feat: 优化页面保护逻辑,提取 guarded page 检查函数

This commit is contained in:
Vixalie
2026-03-26 17:15:04 +08:00
parent 71ee57f93c
commit 899ebf5979

View File

@@ -11,11 +11,15 @@ import type { LayoutLoad } from "./$types";
// See: https://v2.tauri.app/start/frontend/sveltekit/ for more info
export const ssr = false;
function isGuardedPage(pathname: string) {
return !pathname.startsWith("/boot") && !pathname.startsWith("/settings") && !pathname.startsWith("/create");
}
export const load: LayoutLoad = async ({url}) => {
const currentOpenedDataset = get(openedDatasetDir);
console.debug('[Main Load]', currentOpenedDataset, url);
if (isNil(currentOpenedDataset) && url.pathname !== "/boot" && url.pathname !== "/settings") {
if (isNil(currentOpenedDataset) && isGuardedPage(url.pathname)) {
redirect(303, "/boot");
}
}