menu.ts 2.6 KB
Newer Older
陈文彬 已提交
1 2 3 4
import { resultSuccess } from '../_util';
import { MockMethod } from 'vite-plugin-mock';

const dashboardRoute = {
5 6 7 8 9 10 11
  path: '/dashboard',
  name: 'Dashboard',
  component: 'PAGE_LAYOUT',
  redirect: '/dashboard/welcome',
  meta: {
    icon: 'ant-design:home-outlined',
    title: 'Dashboard',
陈文彬 已提交
12
  },
13
  children: [
陈文彬 已提交
14 15 16
    {
      path: '/welcome',
      name: 'Welcome',
V
vben 已提交
17
      component: '/dashboard/welcome/index',
陈文彬 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
      meta: {
        title: '欢迎页',
        affix: true,
      },
    },
  ],
};

const frontRoute = {
  path: '/front',
  name: 'PermissionFrontDemo',
  meta: {
    title: '基于前端权限',
  },
  children: [
    {
      path: 'page',
V
vben 已提交
35
      name: 'FrontPageAuth',
V
vben 已提交
36
      component: '/demo/permission/front/index',
陈文彬 已提交
37 38 39 40 41 42
      meta: {
        title: '页面权限',
      },
    },
    {
      path: 'btn',
V
vben 已提交
43
      name: 'FrontBtnAuth',
V
vben 已提交
44
      component: '/demo/permission/front/Btn',
陈文彬 已提交
45 46 47 48 49 50
      meta: {
        title: '按钮权限',
      },
    },
    {
      path: 'auth-pageA',
V
vben 已提交
51
      name: 'FrontAuthPageA',
V
vben 已提交
52
      component: '/demo/permission/front/AuthPageA',
陈文彬 已提交
53 54 55 56 57 58
      meta: {
        title: '权限测试页A',
      },
    },
    {
      path: 'auth-pageB',
V
vben 已提交
59
      name: 'FrontAuthPageB',
V
vben 已提交
60
      component: '/demo/permission/front/AuthPageB',
陈文彬 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
      meta: {
        title: '权限测试页B',
      },
    },
  ],
};
const backRoute = {
  path: '/back',
  name: 'PermissionBackDemo',
  meta: {
    title: '基于后台权限',
  },
  children: [
    {
      path: 'page',
V
vben 已提交
76
      name: 'BackAuthPage',
V
vben 已提交
77
      component: '/demo/permission/back/index',
陈文彬 已提交
78 79 80 81 82 83
      meta: {
        title: '页面权限',
      },
    },
    {
      path: 'btn',
V
vben 已提交
84
      name: 'BackAuthBtn',
V
vben 已提交
85
      component: '/demo/permission/back/Btn',
陈文彬 已提交
86 87 88 89 90 91 92
      meta: {
        title: '按钮权限',
      },
    },
  ],
};
const authRoute = {
93 94 95 96 97 98 99
  path: '/permission',
  name: 'Permission',
  component: 'PAGE_LAYOUT',
  redirect: '/permission/front/page',
  meta: {
    icon: 'ant-design:home-outlined',
    title: '权限管理',
陈文彬 已提交
100
  },
101
  children: [frontRoute, backRoute],
陈文彬 已提交
102 103 104
};

const authRoute1 = {
105 106 107 108 109 110 111
  path: '/permission',
  name: 'Permission',
  component: 'PAGE_LAYOUT',
  redirect: '/permission/front/page',
  meta: {
    icon: 'ant-design:home-outlined',
    title: '权限管理',
陈文彬 已提交
112
  },
113
  children: [backRoute],
陈文彬 已提交
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
};
export default [
  {
    url: '/api/getMenuListById',
    timeout: 1000,
    method: 'get',
    response: ({ query }) => {
      const { id } = query;
      if (!id || id === '1') {
        return resultSuccess([dashboardRoute, authRoute]);
      }
      if (id === '2') {
        return resultSuccess([dashboardRoute, authRoute1]);
      }
    },
  },
] as MockMethod[];