diff --git a/mock/asyncRoutes.ts b/mock/asyncRoutes.ts index 3ea012d4a..6b750023b 100644 --- a/mock/asyncRoutes.ts +++ b/mock/asyncRoutes.ts @@ -5,7 +5,7 @@ import { MockMethod } from "vite-plugin-mock"; const systemRouter = { path: "/system", name: "system", - redirect: "/system/user", + redirect: "/system/user/index", meta: { icon: "Setting", title: "menus.hssysManagement", @@ -15,7 +15,7 @@ const systemRouter = { }, children: [ { - path: "/system/user", + path: "/system/user/index", name: "user", meta: { title: "menus.hsBaseinfo", @@ -24,7 +24,7 @@ const systemRouter = { } }, { - path: "/system/dict", + path: "/system/dict/index", name: "dict", meta: { title: "menus.hsDict", @@ -39,7 +39,7 @@ const systemRouter = { const permissionRouter = { path: "/permission", name: "permission", - redirect: "/permission/page", + redirect: "/permission/page/index", meta: { title: "menus.permission", icon: "Lollipop", @@ -49,7 +49,7 @@ const permissionRouter = { }, children: [ { - path: "/permission/page", + path: "/permission/page/index", name: "permissionPage", meta: { title: "menus.permissionPage", @@ -58,7 +58,7 @@ const permissionRouter = { } }, { - path: "/permission/button", + path: "/permission/button/index", name: "permissionButton", meta: { title: "menus.permissionButton", diff --git a/src/layout/components/tag/index.vue b/src/layout/components/tag/index.vue index b84bb7bdd..2873f25d6 100644 --- a/src/layout/components/tag/index.vue +++ b/src/layout/components/tag/index.vue @@ -18,7 +18,7 @@ import closeLeft from "/@/assets/svg/close_left.svg"; import closeOther from "/@/assets/svg/close_other.svg"; import closeRight from "/@/assets/svg/close_right.svg"; -import { $t } from "/@/plugins/i18n"; +import { $t as t } from "/@/plugins/i18n"; import { emitter } from "/@/utils/mitt"; import { isEqual, isEmpty } from "lodash-es"; import { transformI18n } from "/@/plugins/i18n"; @@ -189,42 +189,42 @@ const handleScroll = (offset: number): void => { const tagsViews = ref>([ { icon: refresh, - text: $t("buttons.hsreload"), + text: t("buttons.hsreload"), divided: false, disabled: false, show: true }, { icon: close, - text: $t("buttons.hscloseCurrentTab"), + text: t("buttons.hscloseCurrentTab"), divided: false, disabled: multiTags.value.length > 1 ? false : true, show: true }, { icon: closeLeft, - text: $t("buttons.hscloseLeftTabs"), + text: t("buttons.hscloseLeftTabs"), divided: true, disabled: multiTags.value.length > 1 ? false : true, show: true }, { icon: closeRight, - text: $t("buttons.hscloseRightTabs"), + text: t("buttons.hscloseRightTabs"), divided: false, disabled: multiTags.value.length > 1 ? false : true, show: true }, { icon: closeOther, - text: $t("buttons.hscloseOtherTabs"), + text: t("buttons.hscloseOtherTabs"), divided: true, disabled: multiTags.value.length > 2 ? false : true, show: true }, { icon: closeAll, - text: $t("buttons.hscloseAllTabs"), + text: t("buttons.hscloseAllTabs"), divided: false, disabled: multiTags.value.length > 1 ? false : true, show: true diff --git a/src/router/index.ts b/src/router/index.ts index bf6d2339c..98d266716 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -117,8 +117,9 @@ router.beforeEach((to: toRouteType, _from, next) => { route?.meta?.rank !== 0 && routePartent.length === 0 ) { + if (!route?.meta?.refreshRedirect) return; const { name, meta } = findRouteByPath( - route?.meta?.refreshRedirect, + route.meta.refreshRedirect, routes ); handTag( diff --git a/src/router/utils.ts b/src/router/utils.ts index 46de57ebe..b669ea8f6 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -13,7 +13,7 @@ import { useTimeoutFn } from "@vueuse/core"; import { RouteConfigs } from "/@/layout/types"; import { usePermissionStoreHook } from "/@/store/modules/permission"; // https://cn.vitejs.dev/guide/features.html#glob-import -const modulesRoutes = import.meta.glob("/src/views/*/*/*.vue"); +const modulesRoutes = import.meta.glob("/src/views/**/*.{vue,tsx}"); // 动态路由 import { getAsyncRoutes } from "/@/api/routes"; @@ -212,11 +212,13 @@ const handleAliveRoute = (matched: RouteRecordNormalized[], mode?: string) => { // 过滤后端传来的动态路由 重新生成规范路由 const addAsyncRoutes = (arrRoutes: Array) => { if (!arrRoutes || !arrRoutes.length) return; + const modulesRoutesKeys = Object.keys(modulesRoutes); arrRoutes.forEach((v: RouteRecordRaw) => { if (v.redirect) { v.component = Layout; } else { - v.component = modulesRoutes[`/src/views${v.path}/index.vue`]; + const index = modulesRoutesKeys.findIndex(ev => ev.includes(v.path)); + v.component = modulesRoutes[modulesRoutesKeys[index]]; } if (v.children) { addAsyncRoutes(v.children); diff --git a/src/views/tabs/detail/index.vue b/src/views/tabs/detail.vue similarity index 100% rename from src/views/tabs/detail/index.vue rename to src/views/tabs/detail.vue diff --git a/src/views/tabs/index/index.vue b/src/views/tabs/index.vue similarity index 100% rename from src/views/tabs/index/index.vue rename to src/views/tabs/index.vue