Files
training/website/src/App.jsx
T
Pine 4419c9265f feat(user-center): 顶栏用户下拉 + 玻璃个人中心 + 我的报名/任务/园区/认证页
- Header: 登录后头像+用户名玻璃下拉(个人中心/我的报名/我的任务/我的园区/认证中心/退出);未登录显示登录/注册;移动端同步
- Profile: 玻璃用户卡(头像上传/身份标签) + 我的服务宫格(实时状态) + 报名资料 + 登录绑定
- 新增 my-bookings/my-tasks/my-park/my-cert 四页;auth.pickUser 保留 role/account_type;booking/park 新增 myBookings/myParkAdmission
- 新增 user-center.css 玻璃样式;vite build 通过
2026-08-27 20:15:01 +08:00

124 lines
4.3 KiB
React

import React from 'react';
import Home from './user/Home';
import System from './platform/System';
import Structures from './platform/Structures';
import Schedule from './platform/Schedule';
import Cards from './platform/Cards';
import Tools from './platform/Tools';
import OPCTest from './user/OPCTest';
import Events from './user/Events';
import EventDetail from './user/EventDetail';
import PolicyTest from './user/PolicyTest';
import StartPlan from './user/StartPlan';
import OPCSurvey from './user/OPCSurvey';
import Profile from './user/Profile';
import PineHome from './platform/PineHome';
import PineOps from './platform/PineOps';
import PineBookings from './platform/PineBookings';
import PineEvents from './platform/PineEvents';
import PineTests from './platform/PineTests';
import ReportHome from './platform/report/ReportHome';
import ReportBiz from './platform/report/ReportBiz';
import ReportPolicy from './platform/report/ReportPolicy';
import ReportData from './platform/report/ReportData';
import PineLogs from './platform/PineLogs';
import Login from './platform/Login';
import { ParticleField } from './components/organisms';
import { isAuthed } from './services/auth';
import { initTheme } from './services/theme';
import ParkApply from './user/ParkApply';
import CertApply from './user/CertApply';
import ParkTransfer from './user/ParkTransfer';
import Content from './user/Content';
import ContentDetail from './user/ContentDetail';
import Tasks from './user/Tasks';
import TaskDetail from './user/TaskDetail';
import Enterprise from './platform/Enterprise';
import ParkCenter from './platform/ParkCenter';
import MyBookings from './user/MyBookings';
import MyTasks from './user/MyTasks';
import MyPark from './user/MyPark';
import MyCert from './user/MyCert';
/* 公开路由(无需登录) */
const PUBLIC_ROUTES = [
{ path: '', Page: Home },
{ path: 'events', Page: Events },
{ path: 'event-detail', Page: EventDetail },
{ path: 'opc-test', Page: OPCTest },
{ path: 'policy-test', Page: PolicyTest },
{ path: 'start-plan', Page: StartPlan },
{ path: 'survey', Page: OPCSurvey },
{ path: 'park-apply', Page: ParkApply },
{ path: 'cert-apply', Page: CertApply },
{ path: 'park-transfer', Page: ParkTransfer },
{ path: 'content', Page: Content },
{ path: 'content-detail', Page: ContentDetail },
{ path: 'tasks', Page: Tasks },
{ path: 'task-detail', Page: TaskDetail },
{ path: 'enterprise', Page: Enterprise },
{ path: 'park-center', Page: ParkCenter },
{ path: 'profile', Page: Profile },
{ path: 'my-bookings', Page: MyBookings },
{ path: 'my-tasks', Page: MyTasks },
{ path: 'my-park', Page: MyPark },
{ path: 'my-cert', Page: MyCert }
];
/* 内部路由(/pine,需登录) */
const PINE_ROUTES = [
{ path: 'pine', Page: PineHome },
{ path: 'pine/ops', Page: PineOps },
{ path: 'pine/bookings', Page: PineBookings },
{ path: 'pine/events', Page: PineEvents },
{ path: 'pine/tests', Page: PineTests },
{ path: 'pine/logs', Page: PineLogs },
{ path: 'pine/report', Page: ReportHome },
{ path: 'pine/report/biz', Page: ReportBiz },
{ path: 'pine/report/policy', Page: ReportPolicy },
{ path: 'pine/report/data', Page: ReportData },
{ path: 'pine/system', Page: System },
{ path: 'pine/structures', Page: Structures },
{ path: 'pine/schedule', Page: Schedule },
{ path: 'pine/cards', Page: Cards },
{ path: 'pine/tools', Page: Tools }
];
const ALL_ROUTES = [...PUBLIC_ROUTES, ...PINE_ROUTES];
const isPine = (p) => p === 'pine' || p.startsWith('pine/');
function parseHash() {
return window.location.hash.replace(/^#\/?/, '').split('?')[0].trim();
}
export default function App() {
const [path, setPath] = React.useState(parseHash);
React.useEffect(() => {
initTheme();
const onHash = () => setPath(parseHash());
window.addEventListener('hashchange', onHash);
return () => window.removeEventListener('hashchange', onHash);
}, []);
const route = ALL_ROUTES.find((r) => r.path === path) || PUBLIC_ROUTES[0];
// 路由守卫:内部路由未登录 → 登录门(目标路径回传,登录后跳回)
if (isPine(route.path) && !isAuthed()) {
return (
<>
<ParticleField />
<Login target={route.path} />
</>
);
}
const { Page } = route;
return (
<>
<ParticleField />
<Page key={path} />
</>
);
}