提交 | 用户 | age
|
9e5e63
|
1 |
import { resultSuccess, resultError, getRequestToken, requestParams } from '../_util'; |
2f6253
|
2 |
import { MockMethod } from 'vite-plugin-mock'; |
9e5e63
|
3 |
import { createFakeUserList } from './user'; |
2f6253
|
4 |
|
c303ec
|
5 |
// single |
2f6253
|
6 |
const dashboardRoute = { |
1e6698
|
7 |
path: '/dashboard', |
f0b93b
|
8 |
name: 'Welcome', |
1e6698
|
9 |
component: '/dashboard/analysis/index', |
9b61e8
|
10 |
meta: { |
1e6698
|
11 |
title: 'routes.dashboard.analysis', |
c303ec
|
12 |
affix: true, |
5dc822
|
13 |
icon: 'bx:bx-home', |
2f6253
|
14 |
}, |
陈 |
15 |
}; |
|
16 |
|
|
17 |
const backRoute = { |
c303ec
|
18 |
path: 'back', |
2f6253
|
19 |
name: 'PermissionBackDemo', |
陈 |
20 |
meta: { |
c303ec
|
21 |
title: 'routes.demo.permission.back', |
2f6253
|
22 |
}, |
c303ec
|
23 |
|
2f6253
|
24 |
children: [ |
陈 |
25 |
{ |
|
26 |
path: 'page', |
41a4b8
|
27 |
name: 'BackAuthPage', |
dc42d4
|
28 |
component: '/demo/permission/back/index', |
2f6253
|
29 |
meta: { |
c303ec
|
30 |
title: 'routes.demo.permission.backPage', |
2f6253
|
31 |
}, |
陈 |
32 |
}, |
|
33 |
{ |
|
34 |
path: 'btn', |
41a4b8
|
35 |
name: 'BackAuthBtn', |
dc42d4
|
36 |
component: '/demo/permission/back/Btn', |
2f6253
|
37 |
meta: { |
c303ec
|
38 |
title: 'routes.demo.permission.backBtn', |
2f6253
|
39 |
}, |
陈 |
40 |
}, |
|
41 |
], |
|
42 |
}; |
|
43 |
|
9e5e63
|
44 |
const authRoute = { |
9b61e8
|
45 |
path: '/permission', |
V |
46 |
name: 'Permission', |
c303ec
|
47 |
component: 'LAYOUT', |
9b61e8
|
48 |
redirect: '/permission/front/page', |
V |
49 |
meta: { |
c303ec
|
50 |
icon: 'carbon:user-role', |
V |
51 |
title: 'routes.demo.permission.permission', |
2f6253
|
52 |
}, |
9b61e8
|
53 |
children: [backRoute], |
c303ec
|
54 |
}; |
V |
55 |
|
|
56 |
const levelRoute = { |
|
57 |
path: '/level', |
|
58 |
name: 'Level', |
|
59 |
component: 'LAYOUT', |
|
60 |
redirect: '/level/menu1/menu1-1', |
|
61 |
meta: { |
|
62 |
icon: 'carbon:user-role', |
|
63 |
title: 'routes.demo.level.level', |
|
64 |
}, |
|
65 |
|
|
66 |
children: [ |
|
67 |
{ |
|
68 |
path: 'menu1', |
|
69 |
name: 'Menu1Demo', |
|
70 |
meta: { |
|
71 |
title: 'Menu1', |
|
72 |
}, |
|
73 |
children: [ |
|
74 |
{ |
|
75 |
path: 'menu1-1', |
|
76 |
name: 'Menu11Demo', |
|
77 |
meta: { |
|
78 |
title: 'Menu1-1', |
|
79 |
}, |
|
80 |
children: [ |
|
81 |
{ |
|
82 |
path: 'menu1-1-1', |
|
83 |
name: 'Menu111Demo', |
|
84 |
component: '/demo/level/Menu111', |
|
85 |
meta: { |
|
86 |
title: 'Menu111', |
|
87 |
}, |
|
88 |
}, |
|
89 |
], |
|
90 |
}, |
|
91 |
{ |
|
92 |
path: 'menu1-2', |
|
93 |
name: 'Menu12Demo', |
|
94 |
component: '/demo/level/Menu12', |
|
95 |
meta: { |
|
96 |
title: 'Menu1-2', |
|
97 |
}, |
|
98 |
}, |
|
99 |
], |
|
100 |
}, |
|
101 |
{ |
|
102 |
path: 'menu2', |
|
103 |
name: 'Menu2Demo', |
|
104 |
component: '/demo/level/Menu2', |
|
105 |
meta: { |
|
106 |
title: 'Menu2', |
|
107 |
}, |
|
108 |
}, |
|
109 |
], |
2f6253
|
110 |
}; |
9e5e63
|
111 |
|
N |
112 |
const sysRoute = { |
|
113 |
path: '/system', |
|
114 |
name: 'System', |
|
115 |
component: 'LAYOUT', |
|
116 |
redirect: '/system/account', |
|
117 |
meta: { |
|
118 |
icon: 'ion:settings-outline', |
|
119 |
title: 'routes.demo.system.moduleName', |
|
120 |
}, |
|
121 |
children: [ |
|
122 |
{ |
|
123 |
path: 'account', |
|
124 |
name: 'AccountManagement', |
|
125 |
meta: { |
|
126 |
title: 'routes.demo.system.account', |
|
127 |
ignoreKeepAlive: true, |
|
128 |
}, |
|
129 |
component: '/demo/system/account/index', |
|
130 |
}, |
|
131 |
{ |
|
132 |
path: 'role', |
|
133 |
name: 'RoleManagement', |
|
134 |
meta: { |
|
135 |
title: 'routes.demo.system.role', |
|
136 |
ignoreKeepAlive: true, |
|
137 |
}, |
|
138 |
component: '/demo/system/role/index', |
|
139 |
}, |
|
140 |
|
|
141 |
{ |
|
142 |
path: 'menu', |
|
143 |
name: 'MenuManagement', |
|
144 |
meta: { |
|
145 |
title: 'routes.demo.system.menu', |
|
146 |
ignoreKeepAlive: true, |
|
147 |
}, |
|
148 |
component: '/demo/system/menu/index', |
|
149 |
}, |
|
150 |
{ |
|
151 |
path: 'dept', |
|
152 |
name: 'DeptManagement', |
|
153 |
meta: { |
|
154 |
title: 'routes.demo.system.dept', |
|
155 |
ignoreKeepAlive: true, |
|
156 |
}, |
|
157 |
component: '/demo/system/dept/index', |
|
158 |
}, |
|
159 |
{ |
|
160 |
path: 'changePassword', |
|
161 |
name: 'ChangePassword', |
|
162 |
meta: { |
|
163 |
title: 'routes.demo.system.password', |
|
164 |
ignoreKeepAlive: true, |
|
165 |
}, |
|
166 |
component: '/demo/system/password/index', |
|
167 |
}, |
|
168 |
], |
|
169 |
}; |
|
170 |
|
c6b766
|
171 |
const linkRoute = { |
无 |
172 |
path: '/link', |
|
173 |
name: 'Link', |
|
174 |
component: 'LAYOUT', |
|
175 |
meta: { |
|
176 |
icon: 'ion:tv-outline', |
|
177 |
title: 'routes.demo.iframe.frame', |
|
178 |
}, |
|
179 |
children: [ |
|
180 |
{ |
|
181 |
path: 'doc', |
|
182 |
name: 'Doc', |
|
183 |
meta: { |
|
184 |
title: 'routes.demo.iframe.doc', |
|
185 |
frameSrc: 'https://vvbin.cn/doc-next/', |
|
186 |
}, |
|
187 |
}, |
|
188 |
{ |
|
189 |
path: 'https://vvbin.cn/doc-next/', |
|
190 |
name: 'DocExternal', |
|
191 |
component: 'LAYOUT', |
|
192 |
meta: { |
|
193 |
title: 'routes.demo.iframe.docExternal', |
|
194 |
}, |
|
195 |
}, |
|
196 |
], |
|
197 |
}; |
|
198 |
|
2f6253
|
199 |
export default [ |
陈 |
200 |
{ |
9e5e63
|
201 |
url: '/basic-api/getMenuList', |
2f6253
|
202 |
timeout: 1000, |
陈 |
203 |
method: 'get', |
9e5e63
|
204 |
response: (request: requestParams) => { |
N |
205 |
const token = getRequestToken(request); |
|
206 |
if (!token) { |
|
207 |
return resultError('Invalid token!'); |
|
208 |
} |
|
209 |
const checkUser = createFakeUserList().find((item) => item.token === token); |
|
210 |
if (!checkUser) { |
|
211 |
return resultError('Invalid user token!'); |
|
212 |
} |
|
213 |
const id = checkUser.userId; |
2f6253
|
214 |
if (!id || id === '1') { |
c6b766
|
215 |
return resultSuccess([dashboardRoute, authRoute, levelRoute, sysRoute, linkRoute]); |
2f6253
|
216 |
} |
陈 |
217 |
if (id === '2') { |
c6b766
|
218 |
return resultSuccess([dashboardRoute, authRoute, levelRoute, linkRoute]); |
2f6253
|
219 |
} |
陈 |
220 |
}, |
|
221 |
}, |
|
222 |
] as MockMethod[]; |