import { Routes, Route, Navigate, useLocation } from 'react-router-dom' import MobileShell from './layouts/MobileShell.jsx' import LoginPage from './pages/LoginPage.jsx' import MacroPage from './pages/MacroPage.jsx' import MonitorPage from './pages/MonitorPage.jsx' import ServerDetail from './pages/monitor/ServerDetail.jsx' import MePage from './pages/MePage.jsx' import CheckinPage from './pages/checkin/CheckinPage.jsx' import { useAuth } from './auth/AuthContext.jsx' // 默认落地页: 打卡 (V0.2 起打卡是第一个 Tab 且为默认选中) const HOME_PATH = '/checkin' // 已登录访问 /login 自动回默认页 function RedirectIfAuthed({ children }) { const { user, loading } = useAuth() if (loading) return null if (user) return return children } // 未登录访问受保护页面 → 跳 /login function RequireAuth({ children }) { const { user, loading } = useAuth() const location = useLocation() if (loading) return
加载中...
if (!user) return return children } export default function App() { return ( } /> }> {/* 打卡为默认首页 */} } /> } /> {/* 宏观: 报警 / 新闻 / 油价 / 经济数据 / 策略研究 / 经济文章 (V0.2 原首页并入, 默认新闻) */} } /> } /> } /> } /> } /> } /> ) }