@umijs/route-utils
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -12,3 +12,5 @@ import { MenuDataItem } from '../types'; | ||
export declare const genKeysToArray: (menuKey: string) => string[]; | ||
export declare const getMenuMatches: (flatMenuKeys: string[] | undefined, path: string) => string | undefined; | ||
export declare const getMenuMatches: (flatMenuKeys: string[] | undefined, path: string, flatMenus: { | ||
[key: string]: MenuDataItem; | ||
}) => string | undefined; | ||
/** | ||
@@ -15,0 +17,0 @@ * 获取当前的选中菜单列表 |
@@ -24,4 +24,8 @@ import pathToRegexp from 'path-to-regexp'; | ||
}; | ||
export const getMenuMatches = (flatMenuKeys = [], path) => flatMenuKeys | ||
export const getMenuMatches = (flatMenuKeys = [], path, flatMenus) => flatMenuKeys | ||
.filter(item => { | ||
// 如果配置了 hideInMenu 就不需要选中了 | ||
if (flatMenus[item].hideInMenu) { | ||
return false; | ||
} | ||
if (item === '/' && path === '/') { | ||
@@ -62,3 +66,3 @@ return true; | ||
const flatMenuKeys = Object.keys(flatMenus); | ||
const menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/'); | ||
const menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/', flatMenus); | ||
if (!menuPathKey) { | ||
@@ -65,0 +69,0 @@ return []; |
@@ -29,3 +29,9 @@ import pathToRegexp from 'path-to-regexp'; | ||
var path = arguments.length > 1 ? arguments[1] : undefined; | ||
var flatMenus = arguments.length > 2 ? arguments[2] : undefined; | ||
return flatMenuKeys.filter(function (item) { | ||
// 如果配置了 hideInMenu 就不需要选中了 | ||
if (flatMenus[item].hideInMenu) { | ||
return false; | ||
} | ||
if (item === '/' && path === '/') { | ||
@@ -71,3 +77,3 @@ return true; | ||
var flatMenuKeys = Object.keys(flatMenus); | ||
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/'); | ||
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/', flatMenus); | ||
@@ -74,0 +80,0 @@ if (!menuPathKey) { |
@@ -42,3 +42,9 @@ "use strict"; | ||
var path = arguments.length > 1 ? arguments[1] : undefined; | ||
var flatMenus = arguments.length > 2 ? arguments[2] : undefined; | ||
return flatMenuKeys.filter(function (item) { | ||
// 如果配置了 hideInMenu 就不需要选中了 | ||
if (flatMenus[item].hideInMenu) { | ||
return false; | ||
} | ||
if (item === '/' && path === '/') { | ||
@@ -87,3 +93,3 @@ return true; | ||
var flatMenuKeys = Object.keys(flatMenus); | ||
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/'); | ||
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/', flatMenus); | ||
@@ -90,0 +96,0 @@ if (!menuPathKey) { |
{ | ||
"name": "@umijs/route-utils", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "Quickly process the routing of umi", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235808
3318