forked from lencx/ChatGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.tsx
145 lines (139 loc) · 2.94 KB
/
routes.tsx
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { useRoutes } from 'react-router-dom';
import {
SettingOutlined,
BulbOutlined,
SyncOutlined,
FileSyncOutlined,
UserOutlined,
DownloadOutlined,
FormOutlined,
GlobalOutlined,
InfoCircleOutlined,
} from '@ant-design/icons';
import type { MenuProps } from 'antd';
import Settings from '@/view/settings';
import About from '@/view/about';
import Awesome from '@/view/awesome';
import UserCustom from '@/view/model/UserCustom';
import SyncPrompts from '@/view/model/SyncPrompts';
import SyncCustom from '@/view/model/SyncCustom';
import SyncRecord from '@/view/model/SyncRecord';
import Download from '@/view/download';
import Notes from '@/view/notes';
import Markdown from '@/view/markdown';
import Dashboard from '@/view/dashboard';
export type ChatRouteMetaObject = {
label: string;
icon?: React.ReactNode;
};
type ChatRouteObject = {
path: string;
element?: JSX.Element;
hideMenu?: boolean;
meta?: ChatRouteMetaObject;
children?: ChatRouteObject[];
};
export const routes: Array<ChatRouteObject> = [
{
path: '/settings',
element: <Settings />,
meta: {
label: 'Settings',
icon: <SettingOutlined />,
},
},
{
path: '/awesome',
element: <Awesome />,
meta: {
label: 'Awesome',
icon: <GlobalOutlined />,
},
},
{
path: '/notes',
element: <Notes />,
meta: {
label: 'Notes',
icon: <FormOutlined />,
},
},
{
path: '/md/:id',
element: <Markdown />,
hideMenu: true,
},
{
path: '/model',
meta: {
label: 'Language Model',
icon: <BulbOutlined />,
},
children: [
{
path: 'user-custom',
element: <UserCustom />,
meta: {
label: 'User Custom',
icon: <UserOutlined />,
},
},
// --- Sync
{
path: 'sync-prompts',
element: <SyncPrompts />,
meta: {
label: 'Sync Prompts',
icon: <SyncOutlined />,
},
},
{
path: 'sync-custom',
element: <SyncCustom />,
meta: {
label: 'Sync Custom',
icon: <FileSyncOutlined />,
},
},
{
path: 'sync-custom/:id',
element: <SyncRecord />,
hideMenu: true,
},
],
},
{
path: '/download',
element: <Download />,
meta: {
label: 'Download',
icon: <DownloadOutlined />,
},
},
{
path: '/about',
element: <About />,
meta: {
label: 'About',
icon: <InfoCircleOutlined />,
},
},
{
path: '/',
element: <Dashboard />,
hideMenu: true,
},
];
type MenuItem = Required<MenuProps>['items'][number];
export const menuItems: MenuItem[] = routes
.filter((j) => !j.hideMenu)
.map((i) => ({
...i.meta,
key: i.path || '',
children: i?.children
?.filter((j) => !j.hideMenu)
?.map((j) => ({ ...j.meta, key: `${i.path}/${j.path}` || '' })),
}));
export default () => {
return useRoutes(routes);
};