2024-05-11 14:48:02 +08:00
|
|
|
|
// 模拟后端动态生成路由
|
2024-05-27 20:01:23 +08:00
|
|
|
|
import { defineFakeRoute } from 'vite-plugin-fake-server/client';
|
|
|
|
|
import { bills, frame } from '@/router/enums';
|
2024-05-11 14:48:02 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* roles:页面级别权限,这里模拟二种 "admin"、"common"
|
|
|
|
|
* admin:管理员角色
|
|
|
|
|
* common:普通角色
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const frameRouter = {
|
2024-05-27 20:01:23 +08:00
|
|
|
|
path: '/iframe',
|
|
|
|
|
meta: {
|
|
|
|
|
icon: 'ri:links-fill',
|
|
|
|
|
title: 'menus.pureExternalPage',
|
|
|
|
|
rank: frame,
|
|
|
|
|
},
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/embedded',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureEmbeddedDoc',
|
|
|
|
|
},
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/colorhunt',
|
|
|
|
|
name: 'FrameColorHunt',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureColorHuntDoc',
|
|
|
|
|
frameSrc: 'https://colorhunt.co/',
|
|
|
|
|
keepAlive: true,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/uigradients',
|
|
|
|
|
name: 'FrameUiGradients',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureUiGradients',
|
|
|
|
|
frameSrc: 'https://uigradients.com/',
|
|
|
|
|
keepAlive: true,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/ep',
|
|
|
|
|
name: 'FrameEp',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureEpDoc',
|
|
|
|
|
frameSrc: 'https://element-plus.org/zh-CN/',
|
|
|
|
|
keepAlive: true,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/tailwindcss',
|
|
|
|
|
name: 'FrameTailwindcss',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureTailwindcssDoc',
|
|
|
|
|
frameSrc: 'https://tailwindcss.com/docs/installation',
|
|
|
|
|
keepAlive: true,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/vue3',
|
|
|
|
|
name: 'FrameVue',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureVueDoc',
|
|
|
|
|
frameSrc: 'https://cn.vuejs.org/',
|
|
|
|
|
keepAlive: true,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/vite',
|
|
|
|
|
name: 'FrameVite',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureViteDoc',
|
|
|
|
|
frameSrc: 'https://cn.vitejs.dev/',
|
|
|
|
|
keepAlive: true,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/pinia',
|
|
|
|
|
name: 'FramePinia',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.purePiniaDoc',
|
|
|
|
|
frameSrc: 'https://pinia.vuejs.org/zh/index.html',
|
|
|
|
|
keepAlive: true,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/vue-router',
|
|
|
|
|
name: 'FrameRouter',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureRouterDoc',
|
|
|
|
|
frameSrc: 'https://router.vuejs.org/zh/',
|
|
|
|
|
keepAlive: true,
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/iframe/external',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureExternalDoc',
|
|
|
|
|
},
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: '/external',
|
|
|
|
|
name: 'https://pure-admin.github.io/pure-admin-doc',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureExternalLink',
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/pureUtilsLink',
|
|
|
|
|
name: 'https://pure-admin-utils.netlify.app/',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.pureUtilsLink',
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-05-11 14:48:02 +08:00
|
|
|
|
};
|
|
|
|
|
|
2024-05-27 20:01:23 +08:00
|
|
|
|
const bill = {
|
|
|
|
|
path: '/bill',
|
|
|
|
|
meta: { icon: 'ri:bookmark-2-line', title: 'menus.bills', rank: bills },
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
path: '/bill/record/index',
|
|
|
|
|
name: 'billRecord',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.billRecord',
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
auths: ['permission:btn:add', 'permission:btn:edit', 'permission:btn:delete'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/bill/history/index',
|
|
|
|
|
name: 'billHistory',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.billHistory',
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
auths: ['permission:btn:add', 'permission:btn:edit', 'permission:btn:delete'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/bill/count/index',
|
|
|
|
|
name: 'billCount',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'menus.billCount',
|
|
|
|
|
roles: ['admin', 'common'],
|
|
|
|
|
auths: ['permission:btn:add', 'permission:btn:edit', 'permission:btn:delete'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-05-11 14:48:02 +08:00
|
|
|
|
};
|
2024-05-12 02:05:33 +08:00
|
|
|
|
|
2024-05-11 14:48:02 +08:00
|
|
|
|
export default defineFakeRoute([
|
2024-05-27 20:01:23 +08:00
|
|
|
|
{
|
|
|
|
|
url: '/get-async-routes',
|
|
|
|
|
method: 'get',
|
|
|
|
|
response: () => {
|
|
|
|
|
return {
|
|
|
|
|
success: true,
|
|
|
|
|
data: [frameRouter, bill],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-05-11 14:48:02 +08:00
|
|
|
|
]);
|