123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- // 根据角色动态生成路由
- import { MockMethod } from "vite-plugin-mock";
- // http://mockjs.com/examples.html#Object
- const systemRouter = {
- path: "/system",
- redirect: "/system/menuOperator/index",
- meta: {
- icon: "setting",
- title: "系统管理",
- rank: 11
- },
- children: [
- {
- path: "/system/menuOperator/index",
- name: "menuOperator",
- meta: {
- icon: "flUser",
- title: "用户管理"
- }
- },
- {
- path: "/system/oplog/index",
- name: "oplog",
- meta: {
- icon: "role",
- title: "角色管理"
- }
- },
- {
- path: "/system/updates/index",
- name: "updates",
- meta: {
- icon: "dept",
- title: "部门管理"
- }
- }
- ]
- };
- const interestRouter = {
- path: "/interest",
- redirect: "/interest/account/index",
- meta: {
- icon: "setting",
- title: "权限管理",
- rank: 11
- },
- children: [
- {
- path: "/interest/account/index",
- name: "account",
- meta: {
- icon: "flUser",
- title: "用户管理"
- }
- },
- {
- path: "/interest/role/index",
- name: "role",
- meta: {
- icon: "role",
- title: "角色管理"
- }
- },
- {
- path: "/interest/action/index",
- name: "action",
- meta: {
- icon: "dept",
- title: "部门管理"
- }
- },
- {
- path: "/interest/dataShare/index",
- name: "dataShare",
- meta: {
- icon: "dict",
- title: "字典管理"
- }
- },
- {
- path: "/interest/group/index",
- name: "group",
- meta: {
- icon: "dict",
- title: "字典管理"
- }
- }
- ]
- };
- const permissionRouter = {
- path: "/permission",
- redirect: "/permission/page/index",
- meta: {
- title: "权限管理",
- icon: "lollipop",
- rank: 7
- },
- children: [
- {
- path: "/permission/page/index",
- name: "PermissionPage",
- meta: {
- title: "权限管理Page"
- }
- },
- {
- path: "/permission/button/index",
- name: "PermissionButton",
- meta: {
- title: "权限管理Button",
- authority: []
- }
- }
- ]
- };
- const frameRouter = {
- path: "/iframe",
- redirect: "/iframe/pure",
- meta: {
- icon: "monitor",
- title: "外部页面",
- rank: 10
- },
- children: [
- {
- path: "/iframe/pure",
- name: "FramePure",
- meta: {
- title: "平台文档(内嵌)",
- frameSrc: "https://pure-admin-doc.vercel.app"
- }
- },
- {
- path: "/external",
- name: "https://pure-admin-doc.vercel.app",
- meta: {
- title: "平台文档(外链)"
- }
- },
- {
- path: "/iframe/ep",
- name: "FrameEp",
- meta: {
- title: "Element Plus文档(内嵌)",
- frameSrc: "https://element-plus.org/zh-CN/"
- }
- }
- ]
- };
- const tabsRouter = {
- path: "/tabs",
- redirect: "/tabs/index",
- meta: {
- icon: "IF-team-icontabs",
- title: "标签页操作",
- rank: 13
- },
- children: [
- {
- path: "/tabs/index",
- name: "Tabs",
- meta: {
- title: "标签页操作"
- }
- },
- {
- path: "/tabs/detail",
- name: "TabDetail",
- meta: {
- title: "",
- showLink: false,
- dynamicLevel: 3,
- refreshRedirect: "/tabs/index"
- }
- }
- ]
- };
- // 添加不同按钮权限到/permission/button页面中
- function setDifAuthority(authority, routes) {
- console.log(routes.children);
- routes.children[1].meta.authority = [authority];
- return routes;
- }
- export default [
- {
- url: "/getAsyncRoutes",
- method: "get",
- response: ({ query }) => {
- if (query.name === "admin") {
- return {
- code: 0,
- info: [
- tabsRouter,
- frameRouter,
- systemRouter,
- interestRouter,
- setDifAuthority("v-admin", permissionRouter)
- ]
- };
- } else {
- return {
- code: 0,
- info: [tabsRouter, setDifAuthority("v-test", permissionRouter)]
- };
- }
- }
- }
- ] as MockMethod[];
|