diff --git a/.husky/_/commit-msg b/.husky/_/commit-msg index 13018c7..21c69a4 100644 --- a/.husky/_/commit-msg +++ b/.husky/_/commit-msg @@ -1,4 +1,2 @@ #!/usr/bin/env sh -. "$(dirname -- "$0")/husky.sh" - -npx --no-install commitlint --edit $1 +. "${0%/*}/h" \ No newline at end of file diff --git a/.husky/_/pre-commit b/.husky/_/pre-commit index 717bc1a..21c69a4 100644 --- a/.husky/_/pre-commit +++ b/.husky/_/pre-commit @@ -1,4 +1,2 @@ #!/usr/bin/env sh -. "$(dirname "$0")/husky.sh" - -pnpm run lint:lint-staged +. "${0%/*}/h" \ No newline at end of file diff --git a/src/components.d.ts b/src/components.d.ts index 0f9377d..bd1b241 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -5,22 +5,22 @@ // Read more: https://github.com/vuejs/core/pull/3399 export {} -declare module "vue" { +declare module 'vue' { export interface GlobalComponents { - BarcodeDraw: (typeof import("./components/barcode-draw/index.vue"))["default"]; - CodeView: (typeof import("./components/code-view/index.vue"))["default"]; - ExternalLinkPage: (typeof import("./components/external-link-page/index.vue"))["default"]; - FillPage: (typeof import("./components/fill-page/index.vue"))["default"]; - InternalLinkPage: (typeof import("./components/internal-link-page/index.vue"))["default"]; - LangProvider: (typeof import("./components/lang-provider/index.vue"))["default"]; - MainTransition: (typeof import("./components/main-transition/index.vue"))["default"]; - PinyinPro: (typeof import("./components/pinyin-pro/index.vue"))["default"]; - QrcodeDraw: (typeof import("./components/qrcode-draw/index.vue"))["default"]; - RouterLink: (typeof import("vue-router"))["RouterLink"]; - RouterView: (typeof import("vue-router"))["RouterView"]; - SelectIcon: (typeof import("./components/select-icon/index.vue"))["default"]; - SvgAndIcon: (typeof import("./components/svg-and-icon/index.vue"))["default"]; - SvgIcon: (typeof import("./components/svg-icon/index.vue"))["default"]; - VerifyCode: (typeof import("./components/verify-code/index.vue"))["default"]; + BarcodeDraw: typeof import('./components/barcode-draw/index.vue')['default'] + CodeView: typeof import('./components/code-view/index.vue')['default'] + ExternalLinkPage: typeof import('./components/external-link-page/index.vue')['default'] + FillPage: typeof import('./components/fill-page/index.vue')['default'] + InternalLinkPage: typeof import('./components/internal-link-page/index.vue')['default'] + LangProvider: typeof import('./components/lang-provider/index.vue')['default'] + MainTransition: typeof import('./components/main-transition/index.vue')['default'] + PinyinPro: typeof import('./components/pinyin-pro/index.vue')['default'] + QrcodeDraw: typeof import('./components/qrcode-draw/index.vue')['default'] + RouterLink: typeof import('vue-router')['RouterLink'] + RouterView: typeof import('vue-router')['RouterView'] + SelectIcon: typeof import('./components/select-icon/index.vue')['default'] + SvgAndIcon: typeof import('./components/svg-and-icon/index.vue')['default'] + SvgIcon: typeof import('./components/svg-icon/index.vue')['default'] + VerifyCode: typeof import('./components/verify-code/index.vue')['default'] } } diff --git a/src/config/index.ts b/src/config/index.ts new file mode 100644 index 0000000..e1c6663 --- /dev/null +++ b/src/config/index.ts @@ -0,0 +1,4 @@ +// 系统全局配置 + +// 首页地址(默认) +export const HOME_PATH: string = "/home"; diff --git a/src/layout/components/Header/components/Breadcrumb/index.vue b/src/layout/components/Header/components/Breadcrumb/index.vue index 1d0c38e..5ac1f83 100644 --- a/src/layout/components/Header/components/Breadcrumb/index.vue +++ b/src/layout/components/Header/components/Breadcrumb/index.vue @@ -14,10 +14,13 @@ diff --git a/src/mock/_data/system_menu.ts b/src/mock/_data/system_menu.ts index 50c8104..ea7250e 100644 --- a/src/mock/_data/system_menu.ts +++ b/src/mock/_data/system_menu.ts @@ -10,61 +10,132 @@ * * 路由meta对象参数,我们通常将属性放到meta对象中 * meta: { - * title: 菜单栏以及 tabsView 栏、菜单搜索名称(国际化) - * hide: 是否隐藏此路由,不会显示在菜单树,可以访问 - * disable: 是否停用,不会显示在菜单树,且不可访问 - * keepAlive: 是否缓存组件状态 - * affix: 是否固定在 tabsView 栏上 - * link: 是否是超链接菜单,开启外链条件:1、 link:链接地址不为空 2、iframe: false - * iframe: 是否内嵌窗口,开启条件:1、iframe:true 2、link:链接地址不为空 - * roles: 当前路由权限表示,取角色管理。路由控制显示、隐藏。 超级管理员:admin;普通角色:common - * icon: 菜单、tabsView 图标等 - * svgIcon: svg图标 - * sort: 菜单顺序 + * title: 菜单栏以及 tabsView 栏、菜单搜索名称(国际化) + * hide: 是否隐藏此路由,不会显示在菜单树,可以访问 + * disable: 是否停用,不会显示在菜单树,且不可访问 + * keepAlive: 是否缓存组件状态 + * affix: 是否固定在 tabsView 栏上 + * link: 是否是超链接菜单,开启外链条件:1、 link:链接地址不为空 2、iframe: false + * iframe: 是否内嵌窗口,开启条件:1、iframe:true 2、link:链接地址不为空 + * roles: 当前路由权限表示,取角色管理。路由控制显示、隐藏。 超级管理员:admin;普通角色:common + * icon: 菜单、tabsView 图标等 + * svgIcon: svg图标 + * sort: 菜单顺序 * } */ /** * 路由的层级设置 * layout为框架布局,顶层路由 - * layout.children下的路由为menu菜单,例如:首页、系统设置、权限管理,在这里我称它为"一级路由" - * 一级路由下的children则是当前菜单的二级菜单 - * 依此类推 + * layout.children下的路由为menu菜单,例如:首页、系统设置、权限管理等 */ export default [ + // layout-二级路由(主要渲染页面) { - path: "/", - name: "/", - redirect: "/home", - component: "layout", // 容器布局-顶层路由 + id: "01", + parentId: "0", + path: "/home", + name: "home", + component: "home/home", meta: { - keepAlive: true + title: "home", // 国际化 + hide: false, // 是否隐藏此路由 + disable: false, // 是否停用此路由 + keepAlive: false, // 缓存组件状态 + affix: true, // 固定在tagesView栏上 + link: "", // 是否外链 + iframe: false, // 是否内嵌窗口 + roles: ["admin", "common"], // 路由权限 + svgIcon: "home", // 菜单图标 + sort: 1 + } + }, + { + id: "02", + parentId: "0", + path: "/file", + name: "file", + redirect: "/file/document-library", + meta: { + title: "file", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "folder-menu", + sort: 2 }, - // 二级路由-主要渲染页面 children: [ { - path: "/home", - name: "home", - component: "home/home", + id: "0201", + parentId: "02", + path: "/file/document-library", + name: "document-library", + component: "file/document-library/document-library", meta: { - title: "home", // 国际化 - hide: false, // 是否隐藏此路由 - disable: false, // 是否停用此路由 - keepAlive: false, // 缓存组件状态 - affix: true, // 固定在tagesView栏上 - link: "", // 是否外链 - iframe: false, // 是否内嵌窗口 - roles: ["admin", "common"], // 路由权限 - svgIcon: "home", // 菜单图标 + title: "document-library", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1 + } + } + ] + }, + { + id: "03", + parentId: "0", + path: "/table", + name: "table", + redirect: "/table/common-table", + meta: { + title: "table", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "table", + sort: 3 + }, + children: [ + { + id: "0301", + parentId: "03", + path: "/table/common-table", + name: "common-table", + component: "table/common-table/common-table", + meta: { + title: "common-table", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", sort: 1 } }, { - path: "/file", - name: "file", - redirect: "/file/document-library", + id: "0302", + parentId: "03", + path: "/table/custom-table", + name: "custom-table", + component: "table/custom-table/custom-table", meta: { - title: "file", + title: "custom-table", hide: false, disable: false, keepAlive: true, @@ -72,376 +143,136 @@ export default [ link: "", iframe: false, roles: ["admin"], - svgIcon: "folder-menu", + icon: "icon-menu", + sort: 2 + } + } + ] + }, + { + id: "04", + parentId: "0", + path: "/form", + name: "form", + redirect: "/form/common-form", + meta: { + title: "form", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "form", + sort: 4 + }, + children: [ + { + id: "0401", + parentId: "04", + path: "/form/common-form", + name: "common-form", + component: "form/common-form/common-form", + meta: { + title: "common-form", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1 + } + }, + { + id: "0402", + parentId: "04", + path: "/form/step-form", + name: "step-form", + component: "form/step-form/step-form", + meta: { + title: "step-form", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2 + } + } + ] + }, + { + id: "05", + parentId: "0", + path: "/multilevel", + name: "multilevel", + redirect: "/multilevel/second-1", + meta: { + title: "multilevel", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "switch", + sort: 5 + }, + children: [ + { + id: "0501", + parentId: "05", + path: "/multilevel/second-1", + name: "second-1", + component: "multilevel/second/second-1", + meta: { + title: "second-1", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1 + } + }, + { + id: "0502", + parentId: "05", + path: "/multilevel/second-2", + name: "second-2", + redirect: "/multilevel/third-1", + meta: { + title: "second-2", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", sort: 2 }, children: [ { - path: "/file/document-library", - name: "document-library", - component: "file/document-library/document-library", + id: "050201", + parentId: "0502", + path: "/multilevel/third-2", + name: "third-2", + component: "multilevel/third/third-2", meta: { - title: "document-library", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - } - ] - }, - { - path: "/table", - name: "table", - redirect: "/table/common-table", - meta: { - title: "table", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - svgIcon: "table", - sort: 3 - }, - children: [ - { - path: "/table/common-table", - name: "common-table", - component: "table/common-table/common-table", - meta: { - title: "common-table", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/table/custom-table", - name: "custom-table", - component: "table/custom-table/custom-table", - meta: { - title: "custom-table", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2 - } - } - ] - }, - { - path: "/form", - name: "form", - redirect: "/form/common-form", - meta: { - title: "form", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - svgIcon: "form", - sort: 4 - }, - children: [ - { - path: "/form/common-form", - name: "common-form", - component: "form/common-form/common-form", - meta: { - title: "common-form", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/form/step-form", - name: "step-form", - component: "form/step-form/step-form", - meta: { - title: "step-form", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2 - } - } - ] - }, - { - path: "/multilevel", - name: "multilevel", - redirect: "/multilevel/second-1", - meta: { - title: "multilevel", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - svgIcon: "switch", - sort: 5 - }, - children: [ - { - path: "/multilevel/second-1", - name: "second-1", - component: "multilevel/second/second-1", - meta: { - title: "second-1", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/multilevel/second-2", - name: "second-2", - redirect: "/multilevel/third-1", - meta: { - title: "second-2", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2 - }, - children: [ - { - path: "/multilevel/third-2", - name: "third-2", - component: "multilevel/third/third-2", - meta: { - title: "third-2", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2 - } - }, - { - path: "/multilevel/third-1", - name: "third-1", - component: "multilevel/third/third-1", - meta: { - title: "third-1", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/multilevel/third-3", - name: "third-3", - component: "multilevel/third/third-3", - meta: { - title: "third-3", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3 - } - }, - { - path: "/multilevel/third-4", - name: "third-4", - component: "multilevel/third/third-4", - meta: { - title: "third-4", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 4 - } - }, - { - path: "/multilevel/third-5", - name: "third-5", - component: "multilevel/third/third-5", - meta: { - title: "third-5", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 5 - } - }, - { - path: "/multilevel/third-6", - name: "third-6", - component: "multilevel/third/third-6", - meta: { - title: "third-6", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 6 - } - }, - { - path: "/multilevel/third-7", - name: "third-7", - component: "multilevel/third/third-7", - meta: { - title: "third-7", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 7 - } - }, - { - path: "/multilevel/third-8", - name: "third-8", - component: "multilevel/third/third-8", - meta: { - title: "third-8", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 8 - } - }, - { - path: "/multilevel/third-9", - name: "third-9", - component: "multilevel/third/third-9", - meta: { - title: "third-9", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 9 - } - } - ] - } - ] - }, - { - path: "/component", - name: "component", - redirect: "/component/player", - meta: { - title: "component", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - svgIcon: "classify", - sort: 6 - }, - children: [ - { - path: "/component/player", - name: "player", - component: "component/player/player", - meta: { - title: "player", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/component/print", - name: "print", - component: "component/print/print", - meta: { - title: "print", + title: "third-2", hide: false, disable: false, keepAlive: true, @@ -454,11 +285,13 @@ export default [ } }, { - path: "/component/draggable", - name: "draggable", - component: "component/draggable/draggable", + id: "050202", + parentId: "0502", + path: "/multilevel/third-1", + name: "third-1", + component: "multilevel/third/third-1", meta: { - title: "draggable", + title: "third-1", hide: false, disable: false, keepAlive: true, @@ -467,20 +300,39 @@ export default [ iframe: false, roles: ["admin"], icon: "icon-menu", + sort: 1 + } + }, + { + id: "050203", + parentId: "0502", + path: "/multilevel/third-3", + name: "third-3", + component: "multilevel/third/third-3", + meta: { + title: "third-3", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + roles: ["admin"], + icon: "icon-menu", sort: 3 } }, { - path: "/component/editor", - name: "editor", - component: "component/editor/editor", + id: "050204", + parentId: "0502", + path: "/multilevel/third-4", + name: "third-4", + component: "multilevel/third/third-4", meta: { - title: "editor", + title: "third-4", + link: "", hide: false, - disable: false, keepAlive: true, affix: false, - link: "", iframe: false, roles: ["admin"], icon: "icon-menu", @@ -488,16 +340,17 @@ export default [ } }, { - path: "/component/newbie", - name: "newbie", - component: "component/newbie/newbie", + id: "050205", + parentId: "0502", + path: "/multilevel/third-5", + name: "third-5", + component: "multilevel/third/third-5", meta: { - title: "newbie", + title: "third-5", + link: "", hide: false, - disable: false, keepAlive: true, affix: false, - link: "", iframe: false, roles: ["admin"], icon: "icon-menu", @@ -505,16 +358,17 @@ export default [ } }, { - path: "/component/icon-selector", - name: "icon-selector", - component: "component/icon-selector/icon-selector", + id: "050206", + parentId: "0502", + path: "/multilevel/third-6", + name: "third-6", + component: "multilevel/third/third-6", meta: { - title: "icon-selector", + title: "third-6", + link: "", hide: false, - disable: false, keepAlive: true, affix: false, - link: "", iframe: false, roles: ["admin"], icon: "icon-menu", @@ -522,16 +376,17 @@ export default [ } }, { - path: "/component/user-center", - name: "user-center", - component: "component/user-center/user-center", + id: "050207", + parentId: "0502", + path: "/multilevel/third-7", + name: "third-7", + component: "multilevel/third/third-7", meta: { - title: "user-center", - hide: true, - disable: false, + title: "third-7", + link: "", + hide: false, keepAlive: true, affix: false, - link: "", iframe: false, roles: ["admin"], icon: "icon-menu", @@ -539,16 +394,17 @@ export default [ } }, { - path: "/component/fingerprintjs2", - name: "fingerprintjs2", - component: "component/fingerprintjs2/fingerprintjs2", + id: "050208", + parentId: "0502", + path: "/multilevel/third-8", + name: "third-8", + component: "multilevel/third/third-8", meta: { - title: "fingerprintjs2", + title: "third-8", + link: "", hide: false, - disable: false, keepAlive: true, affix: false, - link: "", iframe: false, roles: ["admin"], icon: "icon-menu", @@ -556,64 +412,54 @@ export default [ } }, { - path: "/component/barcode", - name: "barcode", - component: "component/barcode/barcode", + id: "050209", + parentId: "0502", + path: "/multilevel/third-9", + name: "third-9", + component: "multilevel/third/third-9", meta: { - title: "barcode", + title: "third-9", + link: "", hide: false, - disable: false, keepAlive: true, affix: false, - link: "", iframe: false, roles: ["admin"], icon: "icon-menu", sort: 9 } - }, - { - path: "/component/qrcode", - name: "qrcode", - component: "component/qrcode/qrcode", - meta: { - title: "qrcode", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 10 - } - }, - { - path: "/component/pinyin", - name: "pinyin", - component: "component/pinyin/pinyin", - meta: { - title: "pinyin", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 11 - } } ] - }, + } + ] + }, + { + id: "06", + parentId: "0", + path: "/component", + name: "component", + redirect: "/component/player", + meta: { + title: "component", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "classify", + sort: 6 + }, + children: [ { - path: "/directive", - name: "directive", - redirect: "/directive/anti-shake", + id: "0601", + parentId: "06", + path: "/component/player", + name: "player", + component: "component/player/player", meta: { - title: "directive", + title: "player", hide: false, disable: false, keepAlive: true, @@ -621,453 +467,113 @@ export default [ link: "", iframe: false, roles: ["admin"], - svgIcon: "directives", - sort: 7 - }, - children: [ - { - path: "/directive/anti-shake", - name: "anti-shake", - component: "directive/anti-shake/anti-shake", - meta: { - title: "anti-shake", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/directive/throttle", - name: "throttle", - component: "directive/throttle/throttle", - meta: { - title: "throttle", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2 - } - }, - { - path: "/directive/test-directive", - name: "test-directive", - component: "directive/test-directive/test-directive", - meta: { - title: "test-directive", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3 - } - } - ] - }, - { - path: "/personal", - name: "personal", - redirect: "/personal/userinfo", - meta: { - title: "personal", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - svgIcon: "user", - sort: 8 - }, - children: [ - { - path: "/personal/userinfo", - name: "userinfo", - component: "personal/userinfo/userinfo", - meta: { - title: "userinfo", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/personal/user-settings", - name: "user-settings", - component: "personal/user-settings/user-settings", - meta: { - title: "user-settings", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2 - } - } - ] - }, - { - path: "/system", - name: "system", - redirect: "/system/account", - meta: { - title: "system", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - svgIcon: "set", - sort: 9 - }, - children: [ - { - path: "/system/account", - name: "account", - component: "system/account/account", - meta: { - title: "account", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/system/role", - name: "role", - component: "system/role/role", - meta: { - title: "role", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2 - } - }, - { - path: "/system/menu", - name: "menu", - component: "system/menu/menu", - meta: { - title: "menu", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3 - } - }, - { - path: "/system/division", - name: "division", - component: "system/division/division", - meta: { - title: "division", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 4 - } - }, - { - path: "/system/dictionary", - name: "dictionary", - component: "system/dictionary/dictionary", - meta: { - title: "dictionary", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 5 - } - }, - { - path: "/system/log", - name: "log", - component: "system/log/log", - meta: { - title: "log", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 6 - } - } - ] - }, - { - path: "/link", - name: "link", - redirect: "/link/internal", - meta: { - title: "link", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - svgIcon: "link", - sort: 10 - }, - children: [ - { - path: "/link/internal", - name: "internal", - redirect: "/link/internal/uigradients", - meta: { - title: "internal", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1 - }, - children: [ - { - path: "/link/internal/uigradients", - name: "uigradients", - component: "link/internal/internal", - meta: { - title: "uigradients", - hide: false, - keepAlive: true, - disable: false, - affix: false, - link: "https://uigradients.com/#HoneyDew", // 链接 - iframe: true, // 区分是否内链 true内链 false外链 - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/link/internal/color-taking-tool", - name: "color-taking-tool", - component: "link/internal/internal", - meta: { - title: "color-taking-tool", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://photokit.com/colors/eyedropper/?lang=zh", // 链接 - iframe: true, // 区分是否内链 true内链 false外链 - roles: ["admin"], - icon: "icon-menu", - sort: 2 - } - }, - { - path: "/link/internal/grid-generator", - name: "grid-generator", - component: "link/internal/internal", - meta: { - title: "grid-generator", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://cssgrid-generator.netlify.app/", // 链接 - iframe: true, // 区分是否内链 true内链 false外链 - roles: ["admin"], - icon: "icon-menu", - sort: 3 - } - } - ] - }, - { - path: "/link/external", - name: "external", - redirect: "/link/external/link-vue", - meta: { - title: "external", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2 - }, - children: [ - { - path: "/link/external/SnowAdmin-Docs", - name: "SnowAdmin-Docs", - component: "link/external/external", - meta: { - title: "SnowAdmin-Docs", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "http://101.126.93.137:81/", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - roles: ["admin"], - icon: "icon-menu", - sort: 5 - } - }, - { - path: "/link/external/vue", - name: "vue", - component: "link/external/external", - meta: { - title: "vue", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://cn.vuejs.org/", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - roles: ["admin"], - icon: "icon-menu", - sort: 1 - } - }, - { - path: "/link/external/vite", - name: "vite", - component: "link/external/external", - meta: { - title: "vite", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://www.vitejs.net/", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - roles: ["admin"], - icon: "icon-menu", - sort: 2 - } - }, - { - path: "/link/external/github", - name: "github", - component: "link/external/external", - meta: { - title: "github", - hide: false, - disable: true, - keepAlive: true, - affix: false, - link: "https://github.com/WANG-Fan0912/SnowAdmin", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - roles: ["admin"], - icon: "icon-menu", - sort: 3 - } - }, - { - path: "/link/external/juejin", - name: "juejin", - component: "link/external/external", - meta: { - title: "juejin", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://juejin.cn/user/1728883023940600", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - roles: ["admin"], - icon: "icon-menu", - sort: 4 - } - } - ] - } - ] - }, - { - path: "/disable-menu", - name: "disable-menu", - component: "disable-menu/disable-menu", - meta: { - title: "disable-menu", - hide: false, - disable: true, - keepAlive: true, - affix: false, - link: "", - iframe: false, - roles: ["admin"], - svgIcon: "switch", - sort: 11 + icon: "icon-menu", + sort: 1 } }, { - path: "/hide-menu", - name: "hide-menu", - component: "hide-menu/hide-menu", + id: "0602", + parentId: "06", + path: "/component/print", + name: "print", + component: "component/print/print", meta: { - title: "hide-menu", + title: "print", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2 + } + }, + { + id: "0603", + parentId: "06", + path: "/component/draggable", + name: "draggable", + component: "component/draggable/draggable", + meta: { + title: "draggable", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3 + } + }, + { + id: "0604", + parentId: "06", + path: "/component/editor", + name: "editor", + component: "component/editor/editor", + meta: { + title: "editor", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 4 + } + }, + { + id: "0605", + parentId: "06", + path: "/component/newbie", + name: "newbie", + component: "component/newbie/newbie", + meta: { + title: "newbie", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 5 + } + }, + { + id: "0606", + parentId: "06", + path: "/component/icon-selector", + name: "icon-selector", + component: "component/icon-selector/icon-selector", + meta: { + title: "icon-selector", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 6 + } + }, + { + id: "0607", + parentId: "06", + path: "/component/user-center", + name: "user-center", + component: "component/user-center/user-center", + meta: { + title: "user-center", hide: true, disable: false, keepAlive: true, @@ -1075,44 +581,649 @@ export default [ link: "", iframe: false, roles: ["admin"], - svgIcon: "switch", - sort: 12 + icon: "icon-menu", + sort: 7 } }, { - path: "/i18n", - name: "i18n", - component: "i18n/i18n", + id: "0608", + parentId: "06", + path: "/component/fingerprintjs2", + name: "fingerprintjs2", + component: "component/fingerprintjs2/fingerprintjs2", meta: { - title: "i18n", + title: "fingerprintjs2", hide: false, disable: false, keepAlive: true, affix: false, link: "", iframe: false, - roles: ["admin", "common"], - svgIcon: "earth", - sort: 13 + roles: ["admin"], + icon: "icon-menu", + sort: 8 } }, { - path: "/about", - name: "about", - component: "about/about", + id: "0609", + parentId: "06", + path: "/component/barcode", + name: "barcode", + component: "component/barcode/barcode", meta: { - title: "about", + title: "barcode", hide: false, disable: false, keepAlive: true, affix: false, link: "", iframe: false, - roles: ["admin", "common"], - svgIcon: "about", - sort: 14 + roles: ["admin"], + icon: "icon-menu", + sort: 9 + } + }, + { + id: "0610", + parentId: "06", + path: "/component/qrcode", + name: "qrcode", + component: "component/qrcode/qrcode", + meta: { + title: "qrcode", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 10 + } + }, + { + id: "0611", + parentId: "06", + path: "/component/pinyin", + name: "pinyin", + component: "component/pinyin/pinyin", + meta: { + title: "pinyin", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 11 } } ] + }, + { + id: "07", + parentId: "0", + path: "/directive", + name: "directive", + redirect: "/directive/anti-shake", + meta: { + title: "directive", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "directives", + sort: 7 + }, + children: [ + { + id: "0701", + parentId: "07", + path: "/directive/anti-shake", + name: "anti-shake", + component: "directive/anti-shake/anti-shake", + meta: { + title: "anti-shake", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1 + } + }, + { + id: "0702", + parentId: "07", + path: "/directive/throttle", + name: "throttle", + component: "directive/throttle/throttle", + meta: { + title: "throttle", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2 + } + }, + { + id: "0703", + parentId: "07", + path: "/directive/test-directive", + name: "test-directive", + component: "directive/test-directive/test-directive", + meta: { + title: "test-directive", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3 + } + } + ] + }, + { + id: "08", + parentId: "0", + path: "/personal", + name: "personal", + redirect: "/personal/userinfo", + meta: { + title: "personal", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "user", + sort: 8 + }, + children: [ + { + id: "0801", + parentId: "08", + path: "/personal/userinfo", + name: "userinfo", + component: "personal/userinfo/userinfo", + meta: { + title: "userinfo", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1 + } + }, + { + id: "0802", + parentId: "08", + path: "/personal/user-settings", + name: "user-settings", + component: "personal/user-settings/user-settings", + meta: { + title: "user-settings", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2 + } + } + ] + }, + { + id: "09", + parentId: "0", + path: "/system", + name: "system", + redirect: "/system/account", + meta: { + title: "system", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "set", + sort: 9 + }, + children: [ + { + id: "0901", + parentId: "09", + path: "/system/account", + name: "account", + component: "system/account/account", + meta: { + title: "account", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1 + } + }, + { + id: "0902", + parentId: "09", + path: "/system/role", + name: "role", + component: "system/role/role", + meta: { + title: "role", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2 + } + }, + { + id: "0903", + parentId: "09", + path: "/system/menu", + name: "menu", + component: "system/menu/menu", + meta: { + title: "menu", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3 + } + }, + { + id: "0904", + parentId: "09", + path: "/system/division", + name: "division", + component: "system/division/division", + meta: { + title: "division", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 4 + } + }, + { + id: "0905", + parentId: "09", + path: "/system/dictionary", + name: "dictionary", + component: "system/dictionary/dictionary", + meta: { + title: "dictionary", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 5 + } + }, + { + id: "0906", + parentId: "09", + path: "/system/log", + name: "log", + component: "system/log/log", + meta: { + title: "log", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 6 + } + } + ] + }, + { + id: "10", + parentId: "0", + path: "/link", + name: "link", + redirect: "/link/internal", + meta: { + title: "link", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "link", + sort: 10 + }, + children: [ + { + id: "1001", + parentId: "10", + path: "/link/internal", + name: "internal", + redirect: "/link/internal/uigradients", + meta: { + title: "internal", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1 + }, + children: [ + { + id: "100101", + parentId: "1001", + path: "/link/internal/uigradients", + name: "uigradients", + component: "link/internal/internal", + meta: { + title: "uigradients", + hide: false, + keepAlive: true, + disable: false, + affix: false, + link: "https://uigradients.com/#HoneyDew", // 链接 + iframe: true, // 区分是否内链 true内链 false外链 + roles: ["admin"], + icon: "icon-menu", + sort: 1 + } + }, + { + id: "100102", + parentId: "1001", + path: "/link/internal/color-taking-tool", + name: "color-taking-tool", + component: "link/internal/internal", + meta: { + title: "color-taking-tool", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://photokit.com/colors/eyedropper/?lang=zh", // 链接 + iframe: true, // 区分是否内链 true内链 false外链 + roles: ["admin"], + icon: "icon-menu", + sort: 2 + } + }, + { + id: "100103", + parentId: "1001", + path: "/link/internal/grid-generator", + name: "grid-generator", + component: "link/internal/internal", + meta: { + title: "grid-generator", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://cssgrid-generator.netlify.app/", // 链接 + iframe: true, // 区分是否内链 true内链 false外链 + roles: ["admin"], + icon: "icon-menu", + sort: 3 + } + } + ] + }, + { + id: "1002", + parentId: "10", + path: "/link/external", + name: "external", + redirect: "/link/external/link-vue", + meta: { + title: "external", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2 + }, + children: [ + { + id: "100201", + parentId: "1002", + path: "/link/external/SnowAdmin-Docs", + name: "SnowAdmin-Docs", + component: "link/external/external", + meta: { + title: "SnowAdmin-Docs", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "http://101.126.93.137:81/", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + roles: ["admin"], + icon: "icon-menu", + sort: 5 + } + }, + { + id: "100202", + parentId: "1002", + path: "/link/external/vue", + name: "vue", + component: "link/external/external", + meta: { + title: "vue", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://cn.vuejs.org/", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + roles: ["admin"], + icon: "icon-menu", + sort: 1 + } + }, + { + id: "100203", + parentId: "1002", + path: "/link/external/vite", + name: "vite", + component: "link/external/external", + meta: { + title: "vite", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://www.vitejs.net/", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + roles: ["admin"], + icon: "icon-menu", + sort: 2 + } + }, + { + id: "100204", + parentId: "1002", + path: "/link/external/github", + name: "github", + component: "link/external/external", + meta: { + title: "github", + hide: false, + disable: true, + keepAlive: true, + affix: false, + link: "https://github.com/WANG-Fan0912/SnowAdmin", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + roles: ["admin"], + icon: "icon-menu", + sort: 3 + } + }, + { + id: "100205", + parentId: "1002", + path: "/link/external/juejin", + name: "juejin", + component: "link/external/external", + meta: { + title: "juejin", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://juejin.cn/user/1728883023940600", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + roles: ["admin"], + icon: "icon-menu", + sort: 4 + } + } + ] + } + ] + }, + { + id: "11", + parentId: "0", + path: "/disable-menu", + name: "disable-menu", + component: "disable-menu/disable-menu", + meta: { + title: "disable-menu", + hide: false, + disable: true, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "switch", + sort: 11 + } + }, + { + id: "12", + parentId: "0", + path: "/hide-menu", + name: "hide-menu", + component: "hide-menu/hide-menu", + meta: { + title: "hide-menu", + hide: true, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin"], + svgIcon: "switch", + sort: 12 + } + }, + { + id: "13", + parentId: "0", + path: "/i18n", + name: "i18n", + component: "i18n/i18n", + meta: { + title: "i18n", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin", "common"], + svgIcon: "earth", + sort: 13 + } + }, + { + id: "14", + parentId: "0", + path: "/about", + name: "about", + component: "about/about", + meta: { + title: "about", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + roles: ["admin", "common"], + svgIcon: "about", + sort: 14 + } } ]; diff --git a/src/mock/system/menu.ts b/src/mock/system/menu.ts index f14e9f7..871d17c 100644 --- a/src/mock/system/menu.ts +++ b/src/mock/system/menu.ts @@ -14,9 +14,8 @@ import systemMenu from "../_data/system_menu"; * 1、将模块设置为真实模块 * 2、存储路由树,用于生成菜单 * 3、根据树生成一维路由数组 - * 4、动态添加路由,设置完整的路由,二维路由:顶层路由 + 二级的一维路由 - * 5、动态添加路由 - * 6、缓存一维路由 + * 4、动态添加路由 + * 5、缓存一维路由 */ // post请求body,get请求query @@ -30,8 +29,7 @@ export default [ // 这里模拟两个角色,admin、common let userRoles = token === "Admin-Token" ? ["admin"] : ["common"]; const originTree: any = deepClone(systemMenu); - originTree[0].children = treeSort(filterByRole(originTree[0].children, userRoles)); - return resultSuccess(originTree); + return resultSuccess(treeSort(filterByRole(originTree, userRoles))); } } ] as MockMethod[]; diff --git a/src/router/index.ts b/src/router/index.ts index 411aa7e..98822a4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -17,10 +17,10 @@ const router = createRouter({ history: createWebHashHistory(), /** * 设置静态路由,其它的路由通过addRoute动态添加 - * 1、staticRoutes登录页 - * 2、notFoundAndNoPower 添加默认 404、401界面,防止提示 No match found for location with path 'xxx' - * 2、后端控制路由中也需要添加 notFoundAndNoPower 404、401界面 - * 静态添加 notFoundAndNoPower 404、401界面将全屏显示 + * 1、staticRoutes登录页、layout页、默认页面('/') + * 2、notFoundAndNoPower 添加默认 401、500界面,防止提示 No match found for location with path 'xxx' + * 2、后端控制路由中也需要添加 notFoundAndNoPower 401、500界面 + * 静态添加 notFoundAndNoPower 401、500界面将全屏显示 * 如果要 notFoundAndNoPower 在layout容器展示,则需要移除静态添加并将其添加到缓存路由树 */ routes: [...staticRoutes, ...notFoundAndNoPower] diff --git a/src/router/route-output.ts b/src/router/route-output.ts index 67585ec..5a45dbd 100644 --- a/src/router/route-output.ts +++ b/src/router/route-output.ts @@ -4,7 +4,6 @@ import { useRoutesConfigStore } from "@/store/modules/route-config"; import { useThemeConfig } from "@/store/modules/theme-config"; import { deepClone, arrayFlattened } from "@/utils/index"; import { useRoutingMethod } from "@/hooks/useRoutingMethod"; -import Layout from "@/layout/index.vue"; /** * 路由树转一维数组 @@ -67,19 +66,13 @@ export const moduleReplacement = (tree: any) => { /** * 模块匹配 * 1、导入 views 目录及其子目录下的所有 .vue 文件。 - * 2、匹配顶层layout,替换真实模块,layout为应用的基础结构 - * 3、匹配views下的所有文件路径,将模块转换为按需引入的真实模块 - * 4、未匹配上,不做处理 + * 2、匹配views下的所有文件路径,将模块转换为按需引入的真实模块 + * 3、未匹配上,不做处理 */ // 匹配views里面所有的.vue文件 const modules = import.meta.glob("@/views/**/*.vue"); export const moduleMatch = (item: any) => { - // 若是layout,则直接给予顶层layout - if (item.component === "layout") { - // 布局组件是应用的基础结构,在应用启动时就需要被加载,因此不需要按需引入 - return (item.component = Layout); - } - // 其它情况下,匹配每个views文件夹下的文件路径 + // 匹配每个views文件夹下的文件路径 for (const key in modules) { const dir = key.split("views/")[1].replace(".vue", ""); // 若匹配上,则替换真实模块 diff --git a/src/router/route.ts b/src/router/route.ts index 9e6c52e..164707d 100644 --- a/src/router/route.ts +++ b/src/router/route.ts @@ -1,29 +1,35 @@ +import { HOME_PATH } from "@/config/index"; +import Layout from "@/layout/index.vue"; /** * 路由path路径与文件夹名称相同,找文件可以浏览器地址快速查找,方便定位文件 * * 路由meta对象参数,我们通常将属性放到meta对象中 * meta: { - * title: 菜单栏以及 tabsView 栏、菜单搜索名称(国际化) - * hide: 是否隐藏此路由,不会显示在菜单树,可以访问 - * disable: 是否停用,不会显示在菜单树,且不可访问 - * keepAlive: 是否缓存组件状态 - * affix: 是否固定在 tabsView 栏上 - * link: 是否是超链接菜单,开启外链条件:1、 link:链接地址不为空 2、iframe: false - * iframe: 是否内嵌窗口,开启条件:1、iframe:true 2、link:链接地址不为空 - * roles: 当前路由权限表示,取角色管理。路由控制显示、隐藏。 超级管理员:admin;普通角色:common - * icon: 菜单、tabsView 图标等 - * svgIcon: svg图标 - * sort: 排序 + * title: 菜单栏以及 tabsView 栏、菜单搜索名称(国际化) + * hide: 是否隐藏此路由,不会显示在菜单树,可以访问 + * disable: 是否停用,不会显示在菜单树,且不可访问 + * keepAlive: 是否缓存组件状态 + * affix: 是否固定在 tabsView 栏上 + * link: 是否是超链接菜单,开启外链条件:1、 link:链接地址不为空 2、iframe: false + * iframe: 是否内嵌窗口,开启条件:1、iframe:true 2、link:链接地址不为空 + * roles: 当前路由权限表示,取角色管理。路由控制显示、隐藏。 超级管理员:admin;普通角色:common + * icon: 菜单、tabsView 图标等 + * svgIcon: svg图标 + * sort: 菜单顺序 * } */ /** * 静态路由 (默认路由) - * 此路由不要动,用于做静态路由定向,如果要添加路由,请在 `dynamicRoutes数组` 中添加 - * @description 前端控制路由 直接改 dynamicRoutes 中的路由,后端控制则不需要,请求接口路由数据时,覆盖 dynamicRoutes 第一个顶层 children 的内容(全屏,不包括 lauyout 中的路由出口) + * 此路由不要动,用于做静态路由定向,如果要添加路由,请在 `layout-children` 中添加 + * @description 前端控制路由 直接改 mock/_data/system_menu 中的路由,后端控制则不需要 * @returns 返回路由菜单数据 */ export const staticRoutes = [ + { + path: "/", + redirect: HOME_PATH + }, { path: "/login", name: "login", @@ -31,10 +37,18 @@ export const staticRoutes = [ meta: { title: "login" } + }, + { + path: "/layout", + name: "layout", + redirect: HOME_PATH, + component: Layout, // 容器布局-顶层路由 + // 二级路由-主要渲染页面 + children: [] } /** - * 提示:写在这里的为全屏界面,不建议写在这里 - * 非全屏界面,请写在 dynamicRoutes 路由数组中 + * 提示:写在这里的为全屏界面,不建议写在这里非全屏界面,请写在 layout.children 路由数组中 + * */ ]; diff --git a/src/store/modules/route-config.ts b/src/store/modules/route-config.ts index 3383a89..1f59de0 100644 --- a/src/store/modules/route-config.ts +++ b/src/store/modules/route-config.ts @@ -86,9 +86,8 @@ export const routesConfigStore = () => { * 2、将模块设置为真实模块 * 3、存储路由树,用于生成菜单 * 4、根据树生成一维路由数组 - * 5、动态添加路由,设置完整的路由,二维路由:顶层路由 + 二级的一维路由 - * 6、动态添加路由 - * 7、缓存一维路由 + * 5、动态添加路由 + * 6、缓存一维路由 */ async function initSetRouter() { // 1、获取过滤角色权限后的树,后端做排序处理 @@ -96,15 +95,13 @@ export const routesConfigStore = () => { // 2、将模块设置为真实模块 let tree = await moduleReplacement(data); // 3、存储路由树,用于生成菜单 - routeTree.value = tree[0].children; + routeTree.value = tree; // 4、根据树生成一维路由数组 - tree[0].children = linearArray(tree[0].children); - // 5、设置完整的路由,二维路由:顶层路由 + 二级的一维路由 - tree[0].redirect = tree[0].children[0].path; - // 6、动态添加路由 - tree.forEach((route: any) => router.addRoute(route)); - // 7、缓存一维路由 - routeList.value = tree[0].children; + tree = linearArray(tree); + // 5、动态添加路由 + tree.forEach((route: any) => router.addRoute("layout", route)); + // 6、缓存一维路由 + routeList.value = tree; } return { diff --git a/src/views/system/menu/menu.vue b/src/views/system/menu/menu.vue index ba49cd6..67d8230 100644 --- a/src/views/system/menu/menu.vue +++ b/src/views/system/menu/menu.vue @@ -95,7 +95,7 @@ import MenuItemIcon from "@/layout/components/Menu/menu-item-icon.vue"; import dynamicRoutes from "@/mock/_data/system_menu"; const tableData = computed(() => { - return dynamicRoutes[0].children; + return dynamicRoutes; }); const formData = reactive({ form: {