App.tsx
4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { lazy, Suspense } from 'react';
import { Navigate, Route, Routes } from 'react-router-dom';
import { AdminShell } from './layouts/AdminShell';
import { RootLayout } from './layouts/RootLayout';
import { LoginPage } from './routes/login/LoginPage';
import { ProtectedRoute } from './routes/ProtectedRoute';
// 懒加载页面组件(命名导出需要转换)
const AgentEditorPage = lazy(() =>
import('./routes/agents/AgentEditorPage').then((m) => ({ default: m.AgentEditorPage }))
);
const AgentListPage = lazy(() =>
import('./routes/agents/AgentListPage').then((m) => ({ default: m.AgentListPage }))
);
const AgentTagEditorPage = lazy(() =>
import('./routes/agent-tags/AgentTagEditorPage').then((m) => ({ default: m.AgentTagEditorPage }))
);
const AgentTagListPage = lazy(() =>
import('./routes/agent-tags/AgentTagListPage').then((m) => ({ default: m.AgentTagListPage }))
);
const ChannelCodeEditorPage = lazy(() =>
import('./routes/channel-codes/ChannelCodeEditorPage').then((m) => ({ default: m.ChannelCodeEditorPage }))
);
const ChannelCodeListPage = lazy(() =>
import('./routes/channel-codes/ChannelCodeListPage').then((m) => ({ default: m.ChannelCodeListPage }))
);
const ComponentsDemoPage = lazy(() =>
import('./routes/components/ComponentsDemoPage').then((m) => ({ default: m.ComponentsDemoPage }))
);
const OfficialSiteMethodologyPage = lazy(() =>
import('./routes/official-site/OfficialSiteMethodologyPage').then((m) => ({ default: m.OfficialSiteMethodologyPage }))
);
const OfficialSiteAgentDisplayConfigPage = lazy(() =>
import('./routes/official-site-agent-display-config/OfficialSiteAgentDisplayConfigPage').then((m) => ({
default: m.OfficialSiteAgentDisplayConfigPage,
}))
);
const OfficialSiteJobTabListPage = lazy(() =>
import('./routes/official-site-job-tabs/OfficialSiteJobTabListPage').then((m) => ({
default: m.OfficialSiteJobTabListPage,
}))
);
const OfficialSiteJobTabEditorPage = lazy(() =>
import('./routes/official-site-job-tabs/OfficialSiteJobTabEditorPage').then((m) => ({
default: m.OfficialSiteJobTabEditorPage,
}))
);
const SkillListPage = lazy(() =>
import('./routes/skills/SkillListPage').then((m) => ({ default: m.SkillListPage }))
);
// 加载状态组件
function PageLoader() {
return (
<div className="flex h-64 items-center justify-center">
<div className="text-gray-500">加载中...</div>
</div>
);
}
export function App() {
return (
<Suspense fallback={<PageLoader />}>
<Routes>
<Route path="login" element={<LoginPage />} />
<Route element={<ProtectedRoute />}>
<Route element={<AdminShell />}>
<Route index element={<Navigate to="/agents" replace />} />
<Route path="agents" element={<AgentListPage />} />
<Route path="agents/new" element={<AgentEditorPage mode="create" />} />
<Route path="agents/:agentId/edit" element={<AgentEditorPage mode="edit" />} />
<Route path="agent-tags" element={<AgentTagListPage />} />
<Route path="agent-tags/new" element={<AgentTagEditorPage mode="create" />} />
<Route path="agent-tags/:tagId/edit" element={<AgentTagEditorPage mode="edit" />} />
<Route path="channel-codes" element={<ChannelCodeListPage />} />
<Route path="channel-codes/new" element={<ChannelCodeEditorPage mode="create" />} />
<Route path="channel-codes/:codeId/edit" element={<ChannelCodeEditorPage mode="edit" />} />
<Route path="skills" element={<SkillListPage />} />
<Route path="official-site/methodology" element={<OfficialSiteMethodologyPage />} />
<Route path="official-site/job-tabs" element={<OfficialSiteJobTabListPage />} />
<Route path="official-site/job-tabs/new" element={<OfficialSiteJobTabEditorPage mode="create" />} />
<Route path="official-site/job-tabs/:tabId/edit" element={<OfficialSiteJobTabEditorPage mode="edit" />} />
<Route path="official-site/job-tabs/:tabId/agents" element={<OfficialSiteAgentDisplayConfigPage />} />
</Route>
</Route>
<Route element={<RootLayout />}>
<Route path="components" element={<ComponentsDemoPage />} />
</Route>
<Route path="*" element={<Navigate to="/agents" replace />} />
</Routes>
</Suspense>
);
}