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 TaskPage from './pages/task/TaskPage.jsx' import { useAuth } from './auth/AuthContext.jsx' import { PowerSyncProvider } from './lib/powersync/react.jsx' import useKeepInputVisible from './hooks/useKeepInputVisible.js' // 默认落地页: 打卡 (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() { // 全局: 输入框聚焦时滚进可视区 (登录页与内页都覆盖) useKeepInputVisible() return ( } /> }> {/* 打卡为默认首页 */} } /> } /> {/* 任务模块 (V0.2): 首屏(最近项目+当前项目) / 项目列表 / 深链 (T-VW-08/09) */} } /> } /> } /> {/* 宏观: 新闻 / 经济文章 + 外接 ifinance 分类 (动态 tab); 报警已迁至监控 (V0.2.2) */} } /> } /> } /> } /> } /> } /> ) }