refactor(projects): 精简版+动态路由权限初步

This commit is contained in:
Soybean
2022-01-03 22:20:10 +08:00
parent 7a0648dba5
commit de2057f141
354 changed files with 2053 additions and 22117 deletions

View File

@ -1,11 +1,10 @@
import type { MockMethod } from 'vite-plugin-mock';
import type { BackendServiceResult } from '@/interface';
export default [
const apis: MockMethod[] = [
{
url: '/api/getUser',
url: '/mock/getUser',
method: 'get',
response: (): BackendServiceResult => {
response: (): Service.BackendServiceResult => {
return {
code: 200,
message: 'ok',
@ -13,4 +12,6 @@ export default [
};
}
}
] as MockMethod[];
];
export default apis;

View File

@ -1,3 +1,4 @@
import auth from './auth';
import route from './route';
export default [...auth];
export default [...auth, ...route];

95
mock/api/route.ts Normal file
View File

@ -0,0 +1,95 @@
import type { MockMethod } from 'vite-plugin-mock';
const routes: AuthRoute.Route[] = [
{
name: 'dashboard',
path: '/dashboard',
component: 'layout',
children: [
{
name: 'dashboard_analysis',
path: '/dashboard/analysis',
component: 'self',
meta: {
title: '分析页'
}
},
{
name: 'dashboard_workbench',
path: '/dashboard/workbench',
component: 'self',
meta: {
title: '分析页',
permissions: ['super', 'admin']
}
}
],
meta: {
title: '仪表盘',
requiresAuth: true,
icon: 'carbon:dashboard'
}
},
{
name: 'about',
path: '/about',
component: 'layout',
meta: {
title: '关于',
permissions: ['super', 'admin', 'test'],
icon: 'fluent:book-information-24-regular',
single: true
}
},
{
name: 'multi-menu',
path: '/multi-menu',
component: 'layout',
children: [
{
name: 'multi-menu_first',
path: '/multi-menu/first',
component: 'multi',
children: [
{
name: 'multi-menu_first_second',
path: '/multi-menu/first/second',
component: 'self',
meta: {
title: '二级菜单'
}
}
],
meta: {
title: '一级菜单'
}
}
],
meta: {
title: '多级菜单'
}
}
];
const routeHome: AuthRoute.RoutePath = '/dashboard/analysis';
const data: ApiRoute.ResponseRoute = {
routes,
home: routeHome
};
const apis: MockMethod[] = [
{
url: '/mock/getUserRoutes',
method: 'post',
response: (): Service.BackendServiceResult => {
return {
code: 200,
message: 'ok',
data
};
}
}
];
export default apis;