diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index c26491d..a83d540 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -9,27 +9,36 @@ import '../app.css'; const PUBLIC_PATHS = ['/login', '/setup']; - const NO_SIDEBAR_PATHS = ['/login', '/setup']; + const NO_CHROME_PATHS = ['/login', '/setup']; let authChecked = $state(false); let sidebarOpen = $state(false); onMount(async () => { + // localStorage에서 사이드바 상태 복원 + const saved = localStorage.getItem('sidebarOpen'); + if (saved === 'true') sidebarOpen = true; + if (!$isAuthenticated) { await tryRefresh(); } authChecked = true; }); + // 사이드바 상태 저장 + $effect(() => { + if (browser) { + localStorage.setItem('sidebarOpen', String(sidebarOpen)); + } + }); + $effect(() => { if (browser && authChecked && !$isAuthenticated && !PUBLIC_PATHS.some(p => $page.url.pathname.startsWith(p))) { goto('/login'); } }); - // 사이드바 표시 여부 - let showSidebar = $derived($isAuthenticated && !NO_SIDEBAR_PATHS.some(p => $page.url.pathname.startsWith(p))); + let showChrome = $derived($isAuthenticated && !NO_CHROME_PATHS.some(p => $page.url.pathname.startsWith(p))); - // 키보드 단축키 function handleKeydown(e) { if (e.key === '/' && !['INPUT', 'TEXTAREA'].includes(document.activeElement?.tagName)) { e.preventDefault(); @@ -48,57 +57,52 @@
로딩 중...
{:else if $isAuthenticated || PUBLIC_PATHS.some(p => $page.url.pathname.startsWith(p))} - {#if showSidebar} + {#if showChrome}