import { lazy, Suspense, useState } from 'react' import { Routes, Route, Navigate } from 'react-router-dom' import { Toaster } from 'sonner' import { useAuthStore } from './store/authStore' import TopNav from './components/layout/TopNav' import SidebarNav from './components/layout/SidebarNav' import MobileTabBar from './components/layout/MobileTabBar' import PageContainer from './components/layout/PageContainer' import { SkeletonPage } from './components/ui/Skeleton' import OnboardingGuide from './components/OnboardingGuide' const Login = lazy(() => import('./pages/auth/Login')) const Register = lazy(() => import('./pages/auth/Register')) const ForgotPassword = lazy(() => import('./pages/auth/ForgotPassword')) const Dashboard = lazy(() => import('./pages/Dashboard')) const Money = lazy(() => import('./pages/Money')) const SocialInsurance = lazy(() => import('./pages/SocialInsurance')) const Roster = lazy(() => import('./pages/Roster')) const Termination = lazy(() => import('./pages/Termination')) const AIAssistant = lazy(() => import('./pages/AIAssistant')) const Settings = lazy(() => import('./pages/Settings')) const Evidence = lazy(() => import('./pages/Evidence')) const Policies = lazy(() => import('./pages/Policies')) const Attendance = lazy(() => import('./pages/Attendance')) const Templates = lazy(() => import('./pages/Templates')) const AuditLog = lazy(() => import('./pages/AuditLog')) const Notifications = lazy(() => import('./pages/Notifications')) const PortalLogin = lazy(() => import('./pages/portal/PortalLogin')) const Payslip = lazy(() => import('./pages/portal/Payslip')) const MyContract = lazy(() => import('./pages/portal/MyContract')) const Onboarding = lazy(() => import('./pages/portal/Onboarding')) const ContractConfirm = lazy(() => import('./pages/portal/ContractConfirm')) const MyPolicies = lazy(() => import('./pages/portal/MyPolicies')) const MedicalPeriodCalculator = lazy(() => import('./pages/tools/MedicalPeriodCalculator')) const HealthCheck = lazy(() => import('./pages/tools/HealthCheck')) const AnnualValueReport = lazy(() => import('./pages/tools/AnnualValueReport')) function ProtectedRoute({ children }: { children: React.ReactNode }) { const isAuthenticated = useAuthStore((s) => s.isAuthenticated) if (!isAuthenticated) return return <>{children} } function PublicRoute({ children }: { children: React.ReactNode }) { const isAuthenticated = useAuthStore((s) => s.isAuthenticated) if (isAuthenticated) return return <>{children} } function AdminLayout({ children }: { children: React.ReactNode }) { const [sidebarOpen, setSidebarOpen] = useState(false) return (
setSidebarOpen(false)} />
setSidebarOpen(true)} />
}>{children}
) } function PortalLayout({ children }: { children: React.ReactNode }) { return (
}>{children}
) } export default function App() { return ( <> {/* 管理端认证页面 */} }>} /> }>} /> }>} /> {/* 管理端业务页面 */} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* 员工端 */} } /> } /> } /> } /> } /> } /> {/* 兜底 */} } /> ) }