mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 04:18:56 +08:00
fix(menu): make sure the menu is activated correctly
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
- **Icon** 修复 SvgIcon 缺少部分样式的问题
|
- **Icon** 修复 SvgIcon 缺少部分样式的问题
|
||||||
- **LockScreen** 修复锁屏功能可以通过刷新页面或复制 URL 打开新的浏览器标签来跳过锁定状态的问题
|
- **LockScreen** 修复锁屏功能可以通过刷新页面或复制 URL 打开新的浏览器标签来跳过锁定状态的问题
|
||||||
- 修复多个窗口同时打开页面时,`Token` 不会同步的问题
|
- 修复多个窗口同时打开页面时,`Token` 不会同步的问题
|
||||||
|
- **Menu** 修复路由映射模式下,单级菜单刷新不会激活
|
||||||
|
|
||||||
## 2.5.2(2021-06-27)
|
## 2.5.2(2021-06-27)
|
||||||
|
|
||||||
|
15
package.json
15
package.json
@@ -39,7 +39,7 @@
|
|||||||
"@logicflow/extension": "^0.5.0",
|
"@logicflow/extension": "^0.5.0",
|
||||||
"@vueuse/core": "^5.0.3",
|
"@vueuse/core": "^5.0.3",
|
||||||
"@zxcvbn-ts/core": "^1.0.0-beta.0",
|
"@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",
|
"axios": "^0.21.1",
|
||||||
"codemirror": "^5.62.0",
|
"codemirror": "^5.62.0",
|
||||||
"cropperjs": "^1.5.12",
|
"cropperjs": "^1.5.12",
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
"pinia": "^2.0.0-beta.3",
|
"pinia": "^2.0.0-beta.3",
|
||||||
"print-js": "^1.6.0",
|
"print-js": "^1.6.0",
|
||||||
"qrcode": "^1.4.4",
|
"qrcode": "^1.4.4",
|
||||||
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"sortablejs": "^1.13.0",
|
"sortablejs": "^1.13.0",
|
||||||
"tinymce": "^5.8.2",
|
"tinymce": "^5.8.2",
|
||||||
"vditor": "^3.8.5",
|
"vditor": "^3.8.5",
|
||||||
@@ -66,7 +67,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^12.1.4",
|
"@commitlint/cli": "^12.1.4",
|
||||||
"@commitlint/config-conventional": "^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",
|
"@purge-icons/generated": "^0.7.0",
|
||||||
"@types/codemirror": "^5.60.1",
|
"@types/codemirror": "^5.60.1",
|
||||||
"@types/crypto-js": "^4.0.1",
|
"@types/crypto-js": "^4.0.1",
|
||||||
@@ -81,8 +82,8 @@
|
|||||||
"@types/qrcode": "^1.4.0",
|
"@types/qrcode": "^1.4.0",
|
||||||
"@types/qs": "^6.9.6",
|
"@types/qs": "^6.9.6",
|
||||||
"@types/sortablejs": "^1.10.6",
|
"@types/sortablejs": "^1.10.6",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
"@typescript-eslint/eslint-plugin": "^4.28.1",
|
||||||
"@typescript-eslint/parser": "^4.28.0",
|
"@typescript-eslint/parser": "^4.28.1",
|
||||||
"@vitejs/plugin-legacy": "^1.4.3",
|
"@vitejs/plugin-legacy": "^1.4.3",
|
||||||
"@vitejs/plugin-vue": "^1.2.4",
|
"@vitejs/plugin-vue": "^1.2.4",
|
||||||
"@vitejs/plugin-vue-jsx": "^1.1.6",
|
"@vitejs/plugin-vue-jsx": "^1.1.6",
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
"husky": "^6.0.0",
|
"husky": "^6.0.0",
|
||||||
"inquirer": "^8.1.1",
|
"inquirer": "^8.1.1",
|
||||||
"is-ci": "^3.0.0",
|
"is-ci": "^3.0.0",
|
||||||
"jest": "^27.0.5",
|
"jest": "^27.0.6",
|
||||||
"less": "^4.1.1",
|
"less": "^4.1.1",
|
||||||
"lint-staged": "^11.0.0",
|
"lint-staged": "^11.0.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
@@ -113,7 +114,7 @@
|
|||||||
"prettier": "^2.3.2",
|
"prettier": "^2.3.2",
|
||||||
"pretty-quick": "^3.1.1",
|
"pretty-quick": "^3.1.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup-plugin-visualizer": "5.5.0",
|
"rollup-plugin-visualizer": "5.5.1",
|
||||||
"stylelint": "^13.13.1",
|
"stylelint": "^13.13.1",
|
||||||
"stylelint-config-prettier": "^8.0.2",
|
"stylelint-config-prettier": "^8.0.2",
|
||||||
"stylelint-config-standard": "^22.0.0",
|
"stylelint-config-standard": "^22.0.0",
|
||||||
@@ -122,7 +123,7 @@
|
|||||||
"ts-jest": "^27.0.3",
|
"ts-jest": "^27.0.3",
|
||||||
"ts-node": "^10.0.0",
|
"ts-node": "^10.0.0",
|
||||||
"typescript": "4.3.4",
|
"typescript": "4.3.4",
|
||||||
"vite": "2.3.8",
|
"vite": "2.4.0-beta.2",
|
||||||
"vite-plugin-compression": "^0.2.5",
|
"vite-plugin-compression": "^0.2.5",
|
||||||
"vite-plugin-html": "^2.0.7",
|
"vite-plugin-html": "^2.0.7",
|
||||||
"vite-plugin-imagemin": "^0.3.2",
|
"vite-plugin-imagemin": "^0.3.2",
|
||||||
|
@@ -21,10 +21,8 @@
|
|||||||
import type { MenuState } from './types';
|
import type { MenuState } from './types';
|
||||||
import type { Menu as MenuType } from '/@/router/types';
|
import type { Menu as MenuType } from '/@/router/types';
|
||||||
import type { RouteLocationNormalizedLoaded } from 'vue-router';
|
import type { RouteLocationNormalizedLoaded } from 'vue-router';
|
||||||
|
|
||||||
import { defineComponent, computed, ref, unref, reactive, toRefs, watch } from 'vue';
|
import { defineComponent, computed, ref, unref, reactive, toRefs, watch } from 'vue';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
|
|
||||||
import Menu from './components/Menu.vue';
|
import Menu from './components/Menu.vue';
|
||||||
import SimpleSubMenu from './SimpleSubMenu.vue';
|
import SimpleSubMenu from './SimpleSubMenu.vue';
|
||||||
import { listenerRouteChange } from '/@/logics/mitt/routeChange';
|
import { listenerRouteChange } from '/@/logics/mitt/routeChange';
|
||||||
@@ -123,6 +121,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const path = (route || unref(currentRoute)).path;
|
const path = (route || unref(currentRoute)).path;
|
||||||
|
|
||||||
menuState.activeName = path;
|
menuState.activeName = path;
|
||||||
|
|
||||||
setOpenKeys(path);
|
setOpenKeys(path);
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { AppRouteModule } from '/@/router/types';
|
import { AppRouteModule } from '/@/router/types';
|
||||||
import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types';
|
import type { MenuModule, Menu, AppRouteRecordRaw } from '/@/router/types';
|
||||||
|
|
||||||
import { findPath, treeMap } from '/@/utils/helper/treeHelper';
|
import { findPath, treeMap } from '/@/utils/helper/treeHelper';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
import { isUrl } from '/@/utils/is';
|
import { isUrl } from '/@/utils/is';
|
||||||
@@ -36,11 +35,14 @@ export function transformMenuModule(menuModule: MenuModule): Menu {
|
|||||||
return menuList[0];
|
return menuList[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformRouteToMenu(routeModList: AppRouteModule[]) {
|
export function transformRouteToMenu(routeModList: AppRouteModule[], routerMapping = false) {
|
||||||
const cloneRouteModList = cloneDeep(routeModList);
|
const cloneRouteModList = cloneDeep(routeModList);
|
||||||
const routeList: AppRouteRecordRaw[] = [];
|
const routeList: AppRouteRecordRaw[] = [];
|
||||||
|
|
||||||
cloneRouteModList.forEach((item) => {
|
cloneRouteModList.forEach((item) => {
|
||||||
|
if (routerMapping && item.meta.hideChildrenInMenu && typeof item.redirect === 'string') {
|
||||||
|
item.path = item.redirect;
|
||||||
|
}
|
||||||
if (item.meta?.single) {
|
if (item.meta?.single) {
|
||||||
const realItem = item?.children?.[0];
|
const realItem = item?.children?.[0];
|
||||||
realItem && routeList.push(realItem);
|
realItem && routeList.push(realItem);
|
||||||
|
@@ -122,10 +122,11 @@ export const usePermissionStore = defineStore({
|
|||||||
case PermissionModeEnum.ROUTE_MAPPING:
|
case PermissionModeEnum.ROUTE_MAPPING:
|
||||||
routes = filter(asyncRoutes, routeFilter);
|
routes = filter(asyncRoutes, routeFilter);
|
||||||
routes = routes.filter(routeFilter);
|
routes = routes.filter(routeFilter);
|
||||||
const menuList = transformRouteToMenu(asyncRoutes);
|
const menuList = transformRouteToMenu(asyncRoutes, true);
|
||||||
menuList.sort((a, b) => {
|
menuList.sort((a, b) => {
|
||||||
return (a.meta?.orderNo || 0) - (b.meta?.orderNo || 0);
|
return (a.meta?.orderNo || 0) - (b.meta?.orderNo || 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setFrontMenuList(menuList);
|
this.setFrontMenuList(menuList);
|
||||||
// Convert multi-level routing to level 2 routing
|
// Convert multi-level routing to level 2 routing
|
||||||
routes = flatMultiLevelRoutes(routes);
|
routes = flatMultiLevelRoutes(routes);
|
||||||
|
Reference in New Issue
Block a user