feat(frontend): 完成品牌 SVG 与后台 Phase 1 基础切片

This commit is contained in:
yml2213
2026-10-30 12:20:01 +08:00
parent 8d9481c251
commit 97167fa482
25 changed files with 2028 additions and 40 deletions
@@ -0,0 +1,36 @@
import { useEffect } from 'react'
import { Navigate, Outlet, useLocation } from 'react-router-dom'
import { PageLoading } from '@/components/PageLoading'
import { getAdminBasePath, getAdminLoginPath } from '@/shared/api/adminClient'
import { useAdminSessionStore } from '@/stores/adminSession'
export function AdminGuard() {
const location = useLocation()
const admin = useAdminSessionStore(state => state.admin)
const loaded = useAdminSessionStore(state => state.loaded)
const loading = useAdminSessionStore(state => state.loading)
const loadMe = useAdminSessionStore(state => state.loadMe)
useEffect(() => {
if (!loaded && !loading) {
void loadMe()
}
}, [loaded, loading, loadMe])
if (!loaded || loading) {
return <PageLoading tip="正在核对后台会话…" />
}
if (!admin) {
const redirect = encodeURIComponent(location.pathname + location.search)
return <Navigate to={`${getAdminLoginPath()}?redirect=${redirect}`} replace />
}
const changePasswordPath = `${getAdminBasePath()}/change-password`
if (admin.password_must_change && location.pathname !== changePasswordPath) {
return <Navigate to={changePasswordPath} replace />
}
return <Outlet />
}