123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- // 模拟后端动态生成路由
- import { defineFakeRoute } from "vite-plugin-fake-server/client";
- import { system, monitor, permission, frame, tabs } from "@/router/enums";
- /**
- * roles:页面级别权限,这里模拟二种 "admin"、"common"
- * admin:管理员角色
- * common:普通角色
- */
- const systemManagementRouter = {
- path: "/system",
- meta: {
- icon: "ri:settings-3-line",
- title: "menus.pureSysManagement",
- rank: system
- },
- children: [
- {
- path: "/system/user/index",
- name: "SystemUser",
- meta: {
- icon: "ri:admin-line",
- title: "menus.pureUser",
- roles: ["admin"]
- }
- },
- {
- path: "/system/role/index",
- name: "SystemRole",
- meta: {
- icon: "ri:admin-fill",
- title: "menus.pureRole",
- roles: ["admin"]
- }
- },
- {
- path: "/system/menu/index",
- name: "SystemMenu",
- meta: {
- icon: "ep:menu",
- title: "menus.pureSystemMenu",
- roles: ["admin"]
- }
- },
- {
- path: "/system/dept/index",
- name: "SystemDept",
- meta: {
- icon: "ri:git-branch-line",
- title: "menus.pureDept",
- roles: ["admin"]
- }
- }
- ]
- };
- const systemMonitorRouter = {
- path: "/monitor",
- meta: {
- icon: "ep:monitor",
- title: "menus.pureSysMonitor",
- rank: monitor
- },
- children: [
- {
- path: "/monitor/online-user",
- component: "monitor/online/index",
- name: "OnlineUser",
- meta: {
- icon: "ri:user-voice-line",
- title: "menus.pureOnlineUser",
- roles: ["admin"]
- }
- },
- {
- path: "/monitor/login-logs",
- component: "monitor/logs/login/index",
- name: "LoginLog",
- meta: {
- icon: "ri:window-line",
- title: "menus.pureLoginLog",
- roles: ["admin"]
- }
- },
- {
- path: "/monitor/operation-logs",
- component: "monitor/logs/operation/index",
- name: "OperationLog",
- meta: {
- icon: "ri:history-fill",
- title: "menus.pureOperationLog",
- roles: ["admin"]
- }
- },
- {
- path: "/monitor/system-logs",
- component: "monitor/logs/system/index",
- name: "SystemLog",
- meta: {
- icon: "ri:file-search-line",
- title: "menus.pureSystemLog",
- roles: ["admin"]
- }
- }
- ]
- };
- const permissionRouter = {
- path: "/permission",
- meta: {
- title: "menus.purePermission",
- icon: "ep:lollipop",
- rank: permission
- },
- children: [
- {
- path: "/permission/page/index",
- name: "PermissionPage",
- meta: {
- title: "menus.purePermissionPage",
- roles: ["admin", "common"]
- }
- },
- {
- path: "/permission/button/index",
- name: "PermissionButton",
- meta: {
- title: "menus.purePermissionButton",
- roles: ["admin", "common"],
- auths: [
- "permission:btn:add",
- "permission:btn:edit",
- "permission:btn:delete"
- ]
- }
- }
- ]
- };
- const frameRouter = {
- path: "/iframe",
- meta: {
- icon: "ri:links-fill",
- title: "menus.pureExternalPage",
- rank: frame
- },
- children: [
- {
- path: "/iframe/external",
- meta: {
- title: "menus.pureExternalDoc"
- },
- children: [
- {
- path: "/external",
- name: "https://yiming_chang.gitee.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"]
- }
- }
- ]
- },
- {
- 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"]
- }
- }
- ]
- }
- ]
- };
- const tabsRouter = {
- path: "/tabs",
- meta: {
- icon: "ri:bookmark-2-line",
- title: "menus.pureTabs",
- rank: tabs
- },
- children: [
- {
- path: "/tabs/index",
- name: "Tabs",
- meta: {
- title: "menus.pureTabs",
- roles: ["admin", "common"]
- }
- },
- // query 传参模式
- {
- path: "/tabs/query-detail",
- name: "TabQueryDetail",
- meta: {
- // 不在menu菜单中显示
- showLink: false,
- activePath: "/tabs/index",
- roles: ["admin", "common"]
- }
- },
- // params 传参模式
- {
- path: "/tabs/params-detail/:id",
- component: "params-detail",
- name: "TabParamsDetail",
- meta: {
- // 不在menu菜单中显示
- showLink: false,
- activePath: "/tabs/index",
- roles: ["admin", "common"]
- }
- }
- ]
- };
- export default defineFakeRoute([
- {
- url: "/get-async-routes",
- method: "get",
- response: () => {
- return {
- success: true,
- data: [
- systemManagementRouter,
- systemMonitorRouter,
- permissionRouter,
- frameRouter,
- tabsRouter
- ]
- };
- }
- }
- ]);
|