mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 10:33:50 +08:00
9e5e630987
* refactor(api): remove unnecessary userId param 移除getUserInfo、getPermCode、getMenuList接口的userId参数。 这些接口应当始终与当前登录用户相关而无需传递userId。 * fix: fix auth header key case error
195 lines
4.1 KiB
TypeScript
195 lines
4.1 KiB
TypeScript
import { resultSuccess, resultError, getRequestToken, requestParams } from '../_util';
|
|
import { MockMethod } from 'vite-plugin-mock';
|
|
import { createFakeUserList } from './user';
|
|
|
|
// single
|
|
const dashboardRoute = {
|
|
path: '/dashboard',
|
|
name: 'Welcome',
|
|
component: '/dashboard/analysis/index',
|
|
meta: {
|
|
title: 'routes.dashboard.analysis',
|
|
affix: true,
|
|
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: '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',
|
|
},
|
|
],
|
|
};
|
|
|
|
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;
|
|
if (!id || id === '1') {
|
|
return resultSuccess([dashboardRoute, authRoute, levelRoute, sysRoute]);
|
|
}
|
|
if (id === '2') {
|
|
return resultSuccess([dashboardRoute, authRoute, levelRoute]);
|
|
}
|
|
},
|
|
},
|
|
] as MockMethod[];
|