Files
training/website/src/App.jsx
T
Pine 0b264ee9b3 feat(admission): 园区入驻申请 —— 小程序首页按钮+表单 + 网站详细流程
- 小程序: 首页首屏Hero(预约/测评后)加「申请入驻」; pages/park-apply 对照《入园申请表》全字段分区表单+资料上传; utils/parks
- 网站: #/park-apply 7步入驻wizard(选园区→申请人→企业→项目→需求→上传→承诺提交); services/park; 首页入口
- 修复循环请求(getParks入useEffect一次); 输入框样式对齐event-detail
2026-08-26 12:00:09 +08:00

98 lines
3.2 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 ParkApply from './user/ParkApply';
/* 公开路由(无需登录) */
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: 'profile', Page: Profile }
];
/* 内部路由(/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(() => {
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} />
</>
);
}