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
| // 模拟后端动态生成路由
| import { defineFakeRoute } from "vite-plugin-fake-server/client";
|
| /**
| * roles:页面级别权限,这里模拟二种 "admin"、"common"
| * admin:管理员角色
| * common:普通角色
| */
| const permissionRouter = {
| path: "/permission",
| meta: {
| title: "权限管理",
| icon: "ep:lollipop",
| rank: 10
| },
| children: [
| {
| path: "/permission/page/index",
| name: "PermissionPage",
| meta: {
| title: "页面权限",
| roles: ["admin", "common"]
| }
| },
| {
| path: "/permission/button",
| meta: {
| title: "按钮权限",
| roles: ["admin", "common"]
| },
| children: [
| {
| path: "/permission/button/router",
| component: "permission/button/index",
| name: "PermissionButtonRouter",
| meta: {
| title: "路由返回按钮权限",
| auths: [
| "permission:btn:add",
| "permission:btn:edit",
| "permission:btn:delete"
| ]
| }
| },
| {
| path: "/permission/button/login",
| component: "permission/button/perms",
| name: "PermissionButtonLogin",
| meta: {
| title: "登录接口返回按钮权限"
| }
| }
| ]
| }
| ]
| };
|
| export default defineFakeRoute([
| {
| url: "/get-async-routes",
| method: "get",
| response: () => {
| return {
| success: true,
| data: [permissionRouter]
| };
| }
| }
| ]);
|
|