|
1
|
import { resultSuccess, resultError, getRequestToken, requestParams } from '../_util';
|
|
2
|
import { MockMethod } from 'vite-plugin-mock';
|
|
3
|
import { createFakeUserList } from './user';
|
|
4
|
|
vben
authored
|
5
|
// single
|
|
6
|
const dashboardRoute = {
|
Vben
authored
|
7
|
path: '/dashboard',
|
|
8
|
name: 'Welcome',
|
Vben
authored
|
9
|
component: '/dashboard/analysis/index',
|
vben
authored
|
10
|
meta: {
|
Vben
authored
|
11
|
title: 'routes.dashboard.analysis',
|
vben
authored
|
12
|
affix: true,
|
|
13
|
icon: 'bx:bx-home',
|
|
14
15
16
17
|
},
};
const backRoute = {
|
vben
authored
|
18
|
path: 'back',
|
|
19
20
|
name: 'PermissionBackDemo',
meta: {
|
vben
authored
|
21
|
title: 'routes.demo.permission.back',
|
|
22
|
},
|
vben
authored
|
23
|
|
|
24
25
26
|
children: [
{
path: 'page',
|
vben
authored
|
27
|
name: 'BackAuthPage',
|
vben
authored
|
28
|
component: '/demo/permission/back/index',
|
|
29
|
meta: {
|
vben
authored
|
30
|
title: 'routes.demo.permission.backPage',
|
|
31
32
33
34
|
},
},
{
path: 'btn',
|
vben
authored
|
35
|
name: 'BackAuthBtn',
|
vben
authored
|
36
|
component: '/demo/permission/back/Btn',
|
|
37
|
meta: {
|
vben
authored
|
38
|
title: 'routes.demo.permission.backBtn',
|
|
39
40
41
42
43
|
},
},
],
};
|
|
44
|
const authRoute = {
|
vben
authored
|
45
46
|
path: '/permission',
name: 'Permission',
|
vben
authored
|
47
|
component: 'LAYOUT',
|
vben
authored
|
48
49
|
redirect: '/permission/front/page',
meta: {
|
vben
authored
|
50
51
|
icon: 'carbon:user-role',
title: 'routes.demo.permission.permission',
|
|
52
|
},
|
vben
authored
|
53
|
children: [backRoute],
|
|
54
|
};
|
vben
authored
|
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
|
const levelRoute = {
path: '/level',
name: 'Level',
component: 'LAYOUT',
redirect: '/level/menu1/menu1-1',
meta: {
icon: 'carbon:user-role',
title: 'routes.demo.level.level',
},
children: [
{
path: 'menu1',
name: 'Menu1Demo',
meta: {
title: 'Menu1',
},
children: [
{
path: 'menu1-1',
name: 'Menu11Demo',
meta: {
title: 'Menu1-1',
},
children: [
{
path: 'menu1-1-1',
name: 'Menu111Demo',
component: '/demo/level/Menu111',
meta: {
title: 'Menu111',
},
},
],
},
{
path: 'menu1-2',
name: 'Menu12Demo',
component: '/demo/level/Menu12',
meta: {
title: 'Menu1-2',
},
},
],
},
{
path: 'menu2',
name: 'Menu2Demo',
component: '/demo/level/Menu2',
meta: {
title: 'Menu2',
},
},
],
};
|
|
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
const sysRoute = {
path: '/system',
name: 'System',
component: 'LAYOUT',
redirect: '/system/account',
meta: {
icon: 'ion:settings-outline',
title: 'routes.demo.system.moduleName',
},
children: [
{
path: 'account',
name: 'AccountManagement',
meta: {
title: 'routes.demo.system.account',
ignoreKeepAlive: true,
},
component: '/demo/system/account/index',
},
{
path: 'role',
name: 'RoleManagement',
meta: {
title: 'routes.demo.system.role',
ignoreKeepAlive: true,
},
component: '/demo/system/role/index',
},
{
path: 'menu',
name: 'MenuManagement',
meta: {
title: 'routes.demo.system.menu',
ignoreKeepAlive: true,
},
component: '/demo/system/menu/index',
},
{
path: 'dept',
name: 'DeptManagement',
meta: {
title: 'routes.demo.system.dept',
ignoreKeepAlive: true,
},
component: '/demo/system/dept/index',
},
{
path: 'changePassword',
name: 'ChangePassword',
meta: {
title: 'routes.demo.system.password',
ignoreKeepAlive: true,
},
component: '/demo/system/password/index',
},
],
};
|
|
171
172
|
export default [
{
|
|
173
|
url: '/basic-api/getMenuList',
|
|
174
175
|
timeout: 1000,
method: 'get',
|
|
176
177
178
179
180
181
182
183
184
185
|
response: (request: requestParams) => {
const token = getRequestToken(request);
if (!token) {
return resultError('Invalid token!');
}
const checkUser = createFakeUserList().find((item) => item.token === token);
if (!checkUser) {
return resultError('Invalid user token!');
}
const id = checkUser.userId;
|
|
186
|
if (!id || id === '1') {
|
|
187
|
return resultSuccess([dashboardRoute, authRoute, levelRoute, sysRoute]);
|
|
188
189
|
}
if (id === '2') {
|
|
190
|
return resultSuccess([dashboardRoute, authRoute, levelRoute]);
|
|
191
192
193
194
|
}
},
},
] as MockMethod[];
|