vue-pure-admin2/mock/asyncRoutes.ts
RealityBoy 3e93618015
perf: 优化导航样式以及菜单折叠动画 (#408)
* chore: `4.0.0` 版本,正在开发中

* chore: update `element-plus`

* chore: update

* chore: update dependencies

* chore: update

* style: update

* chore: update `dependencies`

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update
2023-02-08 16:09:07 +08:00

211 lines
4.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 模拟后端动态生成路由
import { MockMethod } from "vite-plugin-mock";
import { system, permission, frame, tabs } from "@/router/enums";
/**
* roles页面级别权限这里模拟二种 "admin"、"common"
* admin管理员角色
* common普通角色
*/
const systemRouter = {
path: "/system",
meta: {
icon: "setting",
title: "menus.hssysManagement",
rank: system
},
children: [
{
path: "/system/user/index",
name: "User",
meta: {
icon: "flUser",
title: "menus.hsUser",
roles: ["admin"]
}
},
{
path: "/system/role/index",
name: "Role",
meta: {
icon: "role",
title: "menus.hsRole",
roles: ["admin"]
}
},
{
path: "/system/dept/index",
name: "Dept",
meta: {
icon: "dept",
title: "menus.hsDept",
roles: ["admin"]
}
}
]
};
const permissionRouter = {
path: "/permission",
meta: {
title: "menus.permission",
icon: "lollipop",
rank: permission
},
children: [
{
path: "/permission/page/index",
name: "PermissionPage",
meta: {
title: "menus.permissionPage",
roles: ["admin", "common"]
}
},
{
path: "/permission/button/index",
name: "PermissionButton",
meta: {
title: "menus.permissionButton",
roles: ["admin", "common"],
auths: ["btn_add", "btn_edit", "btn_delete"]
}
}
]
};
const frameRouter = {
path: "/iframe",
meta: {
icon: "monitor",
title: "menus.hsExternalPage",
rank: frame
},
children: [
{
path: "/external",
name: "https://yiming_chang.gitee.io/pure-admin-doc",
meta: {
title: "menus.externalLink",
roles: ["admin", "common"]
}
},
{
path: "/iframe/pure",
name: "FramePure",
meta: {
title: "menus.hsPureDocument",
frameSrc: "https://yiming_chang.gitee.io/pure-admin-doc",
roles: ["admin", "common"]
}
},
{
path: "/iframe/ep",
name: "FrameEp",
meta: {
title: "menus.hsEpDocument",
frameSrc: "https://element-plus.org/zh-CN/",
roles: ["admin", "common"]
}
},
{
path: "/iframe/vue3",
name: "FrameVue",
meta: {
title: "menus.hsVueDocument",
frameSrc: "https://cn.vuejs.org/",
roles: ["admin", "common"]
}
},
{
path: "/iframe/vite",
name: "FrameVite",
meta: {
title: "menus.hsViteDocument",
frameSrc: "https://cn.vitejs.dev/",
roles: ["admin", "common"]
}
},
{
path: "/iframe/pinia",
name: "FramePinia",
meta: {
title: "menus.hsPiniaDocument",
frameSrc: "https://pinia.vuejs.org/zh/index.html",
roles: ["admin", "common"]
}
},
{
path: "/iframe/vue-router",
name: "FrameRouter",
meta: {
title: "menus.hsRouterDocument",
frameSrc: "https://router.vuejs.org/zh/",
roles: ["admin", "common"]
}
},
{
path: "/iframe/tailwindcss",
name: "FrameTailwindcss",
meta: {
title: "menus.hsTailwindcssDocument",
frameSrc: "https://tailwindcss.com/docs/installation",
roles: ["admin", "common"]
}
}
]
};
const tabsRouter = {
path: "/tabs",
meta: {
icon: "IF-pure-iconfont-tabs",
title: "menus.hstabs",
rank: tabs
},
children: [
{
path: "/tabs/index",
name: "Tabs",
meta: {
title: "menus.hstabs",
roles: ["admin", "common"]
}
},
// query 传参模式
{
path: "/tabs/query-detail",
name: "TabQueryDetail",
meta: {
// 不在menu菜单中显示
showLink: false,
roles: ["admin", "common"]
}
},
// params 传参模式
{
path: "/tabs/params-detail/:id",
component: "params-detail",
name: "TabParamsDetail",
meta: {
// 不在menu菜单中显示
showLink: false,
roles: ["admin", "common"]
}
}
]
};
export default [
{
url: "/getAsyncRoutes",
method: "get",
response: () => {
return {
success: true,
data: [systemRouter, permissionRouter, frameRouter, tabsRouter]
};
}
}
] as MockMethod[];