调整dashboard项目结构

This commit is contained in:
mlogclub
2026-04-24 11:27:49 +08:00
parent eb353cbbc8
commit 5fa30d29ef
88 changed files with 71 additions and 40 deletions
+5 -4
View File
@@ -33,6 +33,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const router = useRouter()
const [session, setSession] = useState<AuthSession | null>(null)
const [ready, setReady] = useState(false)
const requiresAuth = pathname?.startsWith("/dashboard") ?? false
const refreshProfile = useCallback(async () => {
const stored = readSession()
@@ -55,7 +56,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
} catch {
clearSession()
setSession(null)
if (pathname && !pathname.startsWith("/login")) {
if (requiresAuth) {
startTransition(() => {
router.replace("/login")
})
@@ -63,7 +64,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
} finally {
setReady(true)
}
}, [pathname, router])
}, [requiresAuth, router])
async function signOut() {
const current = readSession()
@@ -83,12 +84,12 @@ export function AuthProvider({ children }: { children: ReactNode }) {
}
setReady(true)
if (pathname && !pathname.startsWith("/login")) {
if (requiresAuth) {
startTransition(() => {
router.replace("/login")
})
}
}, [pathname, refreshProfile, router])
}, [requiresAuth, refreshProfile, router])
return (
<AuthContext.Provider value={{ session, ready, refreshProfile, signOut }}>