完善个人中心页面

This commit is contained in:
Eamon
2026-09-04 13:21:47 +08:00
parent 6d6d300203
commit f59e929843
27 changed files with 614 additions and 414 deletions

View File

@@ -1,16 +1,9 @@
import { useEffect, useState } from "react"
import { Navigate, useLocation } from "react-router-dom"
import { AUTH_EVENT, isAuthed } from "@/api/token"
import { useProfileStore } from "@/components/stores/profile"
export default function AuthGuard({ children }: { children: React.ReactNode }) {
const location = useLocation()
const [isValid, setIsValid] = useState(isAuthed)
useEffect(() => {
const update = () => setIsValid(isAuthed())
window.addEventListener(AUTH_EVENT, update)
return () => window.removeEventListener(AUTH_EVENT, update)
}, [])
const isValid = useProfileStore(state => state.token !== null)
if (!isValid) {
return (