123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- import { resultSuccess, resultError, getRequestToken, requestParams } from '../_util';
- import { MockMethod } from 'vite-plugin-mock';
- import { createFakeUserList } from './user';
- // single
- const dashboardRoute = {
- path: '/dashboard',
- name: 'Dashboard',
- component: 'LAYOUT',
- redirect: '/dashboard/analysis',
- meta: {
- title: 'routes.dashboard.dashboard',
- hideChildrenInMenu: true,
- icon: 'bx:bx-home',
- },
- children: [
- {
- path: 'analysis',
- name: 'Analysis',
- component: '/dashboard/analysis/index',
- meta: {
- hideMenu: true,
- hideBreadcrumb: true,
- title: 'routes.dashboard.analysis',
- currentActiveMenu: '/dashboard',
- icon: 'bx:bx-home',
- },
- },
- {
- path: 'workbench',
- name: 'Workbench',
- component: '/dashboard/workbench/index',
- meta: {
- hideMenu: true,
- hideBreadcrumb: true,
- title: 'routes.dashboard.workbench',
- currentActiveMenu: '/dashboard',
- icon: 'bx:bx-home',
- },
- },
- ],
- };
- const backRoute = {
- path: 'back',
- name: 'PermissionBackDemo',
- meta: {
- title: 'routes.demo.permission.back',
- },
- children: [
- {
- path: 'page',
- name: 'BackAuthPage',
- component: '/demo/permission/back/index',
- meta: {
- title: 'routes.demo.permission.backPage',
- },
- },
- {
- path: 'btn',
- name: 'BackAuthBtn',
- component: '/demo/permission/back/Btn',
- meta: {
- title: 'routes.demo.permission.backBtn',
- },
- },
- ],
- };
- const authRoute = {
- path: '/permission',
- name: 'Permission',
- component: 'LAYOUT',
- redirect: '/permission/front/page',
- meta: {
- icon: 'carbon:user-role',
- title: 'routes.demo.permission.permission',
- },
- children: [backRoute],
- };
- 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',
- },
- },
- ],
- };
- 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: 'account_detail/:id',
- name: 'AccountDetail',
- meta: {
- hideMenu: true,
- title: 'routes.demo.system.account_detail',
- ignoreKeepAlive: true,
- showMenu: false,
- currentActiveMenu: '/system/account',
- },
- component: '/demo/system/account/AccountDetail',
- },
- {
- 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',
- },
- ],
- };
- const linkRoute = {
- path: '/link',
- name: 'Link',
- component: 'LAYOUT',
- meta: {
- icon: 'ion:tv-outline',
- title: 'routes.demo.iframe.frame',
- },
- children: [
- {
- path: 'doc',
- name: 'Doc',
- meta: {
- title: 'routes.demo.iframe.doc',
- frameSrc: 'https://vvbin.cn/doc-next/',
- },
- },
- {
- path: 'https://vvbin.cn/doc-next/',
- name: 'DocExternal',
- component: 'LAYOUT',
- meta: {
- title: 'routes.demo.iframe.docExternal',
- },
- },
- ],
- };
- export default [
- {
- url: '/basic-api/getMenuList',
- timeout: 1000,
- method: 'get',
- 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;
- let menu: Object[];
- switch (id) {
- case '1':
- dashboardRoute.redirect = dashboardRoute.path + '/' + dashboardRoute.children[0].path;
- menu = [dashboardRoute, authRoute, levelRoute, sysRoute, linkRoute];
- break;
- case '2':
- dashboardRoute.redirect = dashboardRoute.path + '/' + dashboardRoute.children[1].path;
- menu = [dashboardRoute, authRoute, levelRoute, linkRoute];
- break;
- default:
- menu = [];
- }
- return resultSuccess(menu);
- },
- },
- ] as MockMethod[];
|