// 模拟后端动态生成路由 import { MockMethod } from "vite-plugin-mock"; /** * roles:页面级别权限,这里模拟二种 "admin"、"common" * admin:管理员角色 * common:普通角色 */ const systemRouter = { path: "/system", meta: { icon: "setting", title: "menus.hssysManagement", rank: 11 }, 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"] } }, { path: "/system/dict", component: "/system/dict/index", name: "Dict", meta: { icon: "dict", title: "menus.hsDict", keepAlive: true, roles: ["admin"] } } ] }; const permissionRouter = { path: "/permission", meta: { title: "menus.permission", icon: "lollipop", rank: 10 }, children: [ { path: "/permission/page/index", name: "PermissionPage", meta: { roles: ["admin", "common"], title: "menus.permissionPage" } }, { 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: 7 }, children: [ { path: "/iframe/pure", name: "FramePure", meta: { title: "menus.hsPureDocument", frameSrc: "http://yiming_chang.gitee.io/pure-admin-doc", roles: ["admin", "common"] } }, { path: "/external", name: "http://yiming_chang.gitee.io/pure-admin-doc", meta: { title: "menus.externalLink", roles: ["admin", "common"] } }, { path: "/iframe/ep", name: "FrameEp", meta: { title: "menus.hsEpDocument", frameSrc: "https://element-plus.org/zh-CN/", roles: ["admin", "common"] } } ] }; const tabsRouter = { path: "/tabs", meta: { icon: "IF-team-icontabs", title: "menus.hstabs", rank: 13 }, children: [ { path: "/tabs/index", name: "Tabs", meta: { title: "menus.hstabs", roles: ["admin", "common"] } }, { path: "/tabs/query-detail", name: "TabQueryDetail", meta: { // 不在menu菜单中显示 showLink: false, roles: ["admin", "common"] } }, { path: "/tabs/params-detail/:id", component: "params-detail", name: "TabParamsDetail", meta: { showLink: false, roles: ["admin", "common"] } } ] }; export default [ { url: "/getAsyncRoutes", method: "get", response: () => { return { success: true, data: [systemRouter, permissionRouter, frameRouter, tabsRouter] }; } } ] as MockMethod[];