mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
refactor: refactor route
This commit is contained in:
115
mock/sys/menu.ts
115
mock/sys/menu.ts
@@ -1,33 +1,23 @@
|
||||
import { resultSuccess } from '../_util';
|
||||
import { MockMethod } from 'vite-plugin-mock';
|
||||
|
||||
// single
|
||||
const dashboardRoute = {
|
||||
path: '/dashboard',
|
||||
name: 'Dashboard',
|
||||
component: 'PAGE_LAYOUT',
|
||||
redirect: '/dashboard/welcome',
|
||||
path: '/home',
|
||||
name: 'Home',
|
||||
component: '/dashboard/welcome/index',
|
||||
meta: {
|
||||
title: 'routes.dashboard.welcome',
|
||||
affix: true,
|
||||
icon: 'ant-design:home-outlined',
|
||||
title: 'Dashboard',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/welcome',
|
||||
name: 'Welcome',
|
||||
component: '/dashboard/welcome/index',
|
||||
meta: {
|
||||
title: '欢迎页',
|
||||
affix: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const frontRoute = {
|
||||
path: '/front',
|
||||
path: 'front',
|
||||
name: 'PermissionFrontDemo',
|
||||
meta: {
|
||||
title: '基于前端权限',
|
||||
title: 'routes.demo.permission.front',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
@@ -35,7 +25,7 @@ const frontRoute = {
|
||||
name: 'FrontPageAuth',
|
||||
component: '/demo/permission/front/index',
|
||||
meta: {
|
||||
title: '页面权限',
|
||||
title: 'routes.demo.permission.frontPage',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -43,7 +33,7 @@ const frontRoute = {
|
||||
name: 'FrontBtnAuth',
|
||||
component: '/demo/permission/front/Btn',
|
||||
meta: {
|
||||
title: '按钮权限',
|
||||
title: 'routes.demo.permission.frontBtn',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -51,7 +41,7 @@ const frontRoute = {
|
||||
name: 'FrontAuthPageA',
|
||||
component: '/demo/permission/front/AuthPageA',
|
||||
meta: {
|
||||
title: '权限测试页A',
|
||||
title: 'routes.demo.permission.frontTestA',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -59,24 +49,25 @@ const frontRoute = {
|
||||
name: 'FrontAuthPageB',
|
||||
component: '/demo/permission/front/AuthPageB',
|
||||
meta: {
|
||||
title: '权限测试页B',
|
||||
title: 'routes.demo.permission.frontTestB',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
const backRoute = {
|
||||
path: '/back',
|
||||
path: 'back',
|
||||
name: 'PermissionBackDemo',
|
||||
meta: {
|
||||
title: '基于后台权限',
|
||||
title: 'routes.demo.permission.back',
|
||||
},
|
||||
|
||||
children: [
|
||||
{
|
||||
path: 'page',
|
||||
name: 'BackAuthPage',
|
||||
component: '/demo/permission/back/index',
|
||||
meta: {
|
||||
title: '页面权限',
|
||||
title: 'routes.demo.permission.backPage',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -84,7 +75,7 @@ const backRoute = {
|
||||
name: 'BackAuthBtn',
|
||||
component: '/demo/permission/back/Btn',
|
||||
meta: {
|
||||
title: '按钮权限',
|
||||
title: 'routes.demo.permission.backBtn',
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -92,11 +83,11 @@ const backRoute = {
|
||||
const authRoute = {
|
||||
path: '/permission',
|
||||
name: 'Permission',
|
||||
component: 'PAGE_LAYOUT',
|
||||
component: 'LAYOUT',
|
||||
redirect: '/permission/front/page',
|
||||
meta: {
|
||||
icon: 'ant-design:home-outlined',
|
||||
title: '权限管理',
|
||||
icon: 'carbon:user-role',
|
||||
title: 'routes.demo.permission.permission',
|
||||
},
|
||||
children: [frontRoute, backRoute],
|
||||
};
|
||||
@@ -104,14 +95,70 @@ const authRoute = {
|
||||
const authRoute1 = {
|
||||
path: '/permission',
|
||||
name: 'Permission',
|
||||
component: 'PAGE_LAYOUT',
|
||||
component: 'LAYOUT',
|
||||
redirect: '/permission/front/page',
|
||||
meta: {
|
||||
icon: 'ant-design:home-outlined',
|
||||
title: '权限管理',
|
||||
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',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
export default [
|
||||
{
|
||||
url: '/api/getMenuListById',
|
||||
@@ -120,10 +167,10 @@ export default [
|
||||
response: ({ query }) => {
|
||||
const { id } = query;
|
||||
if (!id || id === '1') {
|
||||
return resultSuccess([dashboardRoute, authRoute]);
|
||||
return resultSuccess([dashboardRoute, authRoute, levelRoute]);
|
||||
}
|
||||
if (id === '2') {
|
||||
return resultSuccess([dashboardRoute, authRoute1]);
|
||||
return resultSuccess([dashboardRoute, authRoute1, levelRoute]);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user