Browse Source

fix(menu): make sure the menu is activated correctly

Vben 3 years ago
parent
commit
cdb10cc4ac

+ 1 - 0
CHANGELOG.zh_CN.md

@@ -13,6 +13,7 @@
 - **Icon** 修复 SvgIcon 缺少部分样式的问题
 - **LockScreen** 修复锁屏功能可以通过刷新页面或复制 URL 打开新的浏览器标签来跳过锁定状态的问题
 - 修复多个窗口同时打开页面时,`Token` 不会同步的问题
+- **Menu** 修复路由映射模式下,单级菜单刷新不会激活
 
 ## 2.5.2(2021-06-27)
 

+ 8 - 7
package.json

@@ -39,7 +39,7 @@
     "@logicflow/extension": "^0.5.0",
     "@vueuse/core": "^5.0.3",
     "@zxcvbn-ts/core": "^1.0.0-beta.0",
-    "ant-design-vue": "2.2.0-beta.6",
+    "ant-design-vue": "2.2.0-rc.1",
     "axios": "^0.21.1",
     "codemirror": "^5.62.0",
     "cropperjs": "^1.5.12",
@@ -53,6 +53,7 @@
     "pinia": "^2.0.0-beta.3",
     "print-js": "^1.6.0",
     "qrcode": "^1.4.4",
+    "resize-observer-polyfill": "^1.5.1",
     "sortablejs": "^1.13.0",
     "tinymce": "^5.8.2",
     "vditor": "^3.8.5",
@@ -66,7 +67,7 @@
   "devDependencies": {
     "@commitlint/cli": "^12.1.4",
     "@commitlint/config-conventional": "^12.1.4",
-    "@iconify/json": "^1.1.362",
+    "@iconify/json": "^1.1.364",
     "@purge-icons/generated": "^0.7.0",
     "@types/codemirror": "^5.60.1",
     "@types/crypto-js": "^4.0.1",
@@ -81,8 +82,8 @@
     "@types/qrcode": "^1.4.0",
     "@types/qs": "^6.9.6",
     "@types/sortablejs": "^1.10.6",
-    "@typescript-eslint/eslint-plugin": "^4.28.0",
-    "@typescript-eslint/parser": "^4.28.0",
+    "@typescript-eslint/eslint-plugin": "^4.28.1",
+    "@typescript-eslint/parser": "^4.28.1",
     "@vitejs/plugin-legacy": "^1.4.3",
     "@vitejs/plugin-vue": "^1.2.4",
     "@vitejs/plugin-vue-jsx": "^1.1.6",
@@ -105,7 +106,7 @@
     "husky": "^6.0.0",
     "inquirer": "^8.1.1",
     "is-ci": "^3.0.0",
-    "jest": "^27.0.5",
+    "jest": "^27.0.6",
     "less": "^4.1.1",
     "lint-staged": "^11.0.0",
     "npm-run-all": "^4.1.5",
@@ -113,7 +114,7 @@
     "prettier": "^2.3.2",
     "pretty-quick": "^3.1.1",
     "rimraf": "^3.0.2",
-    "rollup-plugin-visualizer": "5.5.0",
+    "rollup-plugin-visualizer": "5.5.1",
     "stylelint": "^13.13.1",
     "stylelint-config-prettier": "^8.0.2",
     "stylelint-config-standard": "^22.0.0",
@@ -122,7 +123,7 @@
     "ts-jest": "^27.0.3",
     "ts-node": "^10.0.0",
     "typescript": "4.3.4",
-    "vite": "2.3.8",
+    "vite": "2.4.0-beta.2",
     "vite-plugin-compression": "^0.2.5",
     "vite-plugin-html": "^2.0.7",
     "vite-plugin-imagemin": "^0.3.2",

+ 1 - 2
src/components/SimpleMenu/src/SimpleMenu.vue

@@ -21,10 +21,8 @@
   import type { MenuState } from './types';
   import type { Menu as MenuType } from '/@/router/types';
   import type { RouteLocationNormalizedLoaded } from 'vue-router';
-
   import { defineComponent, computed, ref, unref, reactive, toRefs, watch } from 'vue';
   import { useDesign } from '/@/hooks/web/useDesign';
-
   import Menu from './components/Menu.vue';
   import SimpleSubMenu from './SimpleSubMenu.vue';
   import { listenerRouteChange } from '/@/logics/mitt/routeChange';
@@ -123,6 +121,7 @@
           return;
         }
         const path = (route || unref(currentRoute)).path;
+
         menuState.activeName = path;
 
         setOpenKeys(path);

+ 4 - 2
src/router/helper/menuHelper.ts

@@ -1,6 +1,5 @@
 import { AppRouteModule } from '/@/router/types';
 import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types';
-
 import { findPath, treeMap } from '/@/utils/helper/treeHelper';
 import { cloneDeep } from 'lodash-es';
 import { isUrl } from '/@/utils/is';
@@ -36,11 +35,14 @@ export function transformMenuModule(menuModule: MenuModule): Menu {
   return menuList[0];
 }
 
-export function transformRouteToMenu(routeModList: AppRouteModule[]) {
+export function transformRouteToMenu(routeModList: AppRouteModule[], routerMapping = false) {
   const cloneRouteModList = cloneDeep(routeModList);
   const routeList: AppRouteRecordRaw[] = [];
 
   cloneRouteModList.forEach((item) => {
+    if (routerMapping && item.meta.hideChildrenInMenu && typeof item.redirect === 'string') {
+      item.path = item.redirect;
+    }
     if (item.meta?.single) {
       const realItem = item?.children?.[0];
       realItem && routeList.push(realItem);

+ 2 - 1
src/store/modules/permission.ts

@@ -122,10 +122,11 @@ export const usePermissionStore = defineStore({
         case PermissionModeEnum.ROUTE_MAPPING:
           routes = filter(asyncRoutes, routeFilter);
           routes = routes.filter(routeFilter);
-          const menuList = transformRouteToMenu(asyncRoutes);
+          const menuList = transformRouteToMenu(asyncRoutes, true);
           menuList.sort((a, b) => {
             return (a.meta?.orderNo || 0) - (b.meta?.orderNo || 0);
           });
+
           this.setFrontMenuList(menuList);
           // Convert multi-level routing to level 2 routing
           routes = flatMultiLevelRoutes(routes);

File diff suppressed because it is too large
+ 371 - 388
yarn.lock


Some files were not shown because too many files changed in this diff