头部统一 - 新增 PageHeader 组件: 高度 23px (原 NavBar 45px 的一半), 标题 12px 主色加粗, 背景取页面底色 - 打卡 / 宏观 / 监控 三页各自引用, 互不影响; 宏观与监控补齐「宏观」「监控」标题 - 「我」页移除 NavBar 空白条, 蓝色头像区直接贴顶 (不引用 PageHeader, 与其余三页解耦) - 清理失效样式 .me-navbar 清单模板分类 - 分段由 2 项扩为 3 项: 进行中 / 已归档 / 模板; 右上角按钮随分段切换 - 模板独立增删改查: 新增 GET /templates/:id、PUT /templates/:id; 预置模板拒绝改删 - 模板按名称字母顺序排序 (Intl.Collator zh-Hans-CN, 中文按拼音/数字按数值), 前后端同口径 - 新建清单去掉场景选择器, 仅保留名称; scene 改为沿用模板自带场景 - 模板改为从右侧滑出 78vw 面板选择, 首项「不使用模板」 宏观 tab - 顺序改为 报警 → 新闻 → 油价 → 经济数据 → 策略研究 → 经济文章, 默认选中新闻 - /macro 由路由直接重定向到 /macro/news, activeFromPath 兜底同样返回 news - SwipeTabs 增加右侧溢出提示: 渐变遮罩 + 主色圆底箭头, 可点击向右翻页, 滚到末尾自动消失 - 切换 tab 时自动把激活项滚到可视区中央
49 lines
2.0 KiB
React
49 lines
2.0 KiB
React
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 <Navigate to={HOME_PATH} replace />
|
|
return children
|
|
}
|
|
|
|
// 未登录访问受保护页面 → 跳 /login
|
|
function RequireAuth({ children }) {
|
|
const { user, loading } = useAuth()
|
|
const location = useLocation()
|
|
if (loading) return <div className="page-loading">加载中...</div>
|
|
if (!user) return <Navigate to="/login" state={{ from: location }} replace />
|
|
return children
|
|
}
|
|
|
|
export default function App() {
|
|
return (
|
|
<Routes>
|
|
<Route path="/login" element={<RedirectIfAuthed><LoginPage /></RedirectIfAuthed>} />
|
|
<Route element={<RequireAuth><MobileShell /></RequireAuth>}>
|
|
{/* 打卡为默认首页 */}
|
|
<Route path="/" element={<Navigate to={HOME_PATH} replace />} />
|
|
<Route path="/checkin" element={<CheckinPage />} />
|
|
{/* 宏观: 报警 / 新闻 / 油价 / 经济数据 / 策略研究 / 经济文章 (V0.2 原首页并入, 默认新闻) */}
|
|
<Route path="/macro" element={<Navigate to="/macro/news" replace />} />
|
|
<Route path="/macro/*" element={<MacroPage />} />
|
|
<Route path="/monitor" element={<MonitorPage />} />
|
|
<Route path="/monitor/server/:uuid" element={<ServerDetail />} />
|
|
<Route path="/me" element={<MePage />} />
|
|
</Route>
|
|
<Route path="*" element={<Navigate to={HOME_PATH} replace />} />
|
|
</Routes>
|
|
)
|
|
} |