@umijs/route-utils
Advanced tools
Comparing version 1.0.25 to 1.0.26
@@ -12,3 +12,8 @@ /** | ||
} | ||
menus[item.key || item.path || '/'] = { ...item }; | ||
if (item.path !== '/') { | ||
menus[item.path || item.key || '/'] = { ...item }; | ||
} | ||
else { | ||
menus[item.key || item.path || '/'] = { ...item }; | ||
} | ||
if (item.children) { | ||
@@ -15,0 +20,0 @@ menus = { ...menus, ...getFlatMenus(item.children) }; |
@@ -290,2 +290,60 @@ import getMatchMenu from './getMatchMenu'; | ||
}); | ||
test('test yfd layout config', () => { | ||
let openMenuItems = getMatchMenu('/bkmng/authority/my', [ | ||
{ | ||
path: '/', | ||
redirect: '/bkmng/authority/my', | ||
exact: true, | ||
unaccessible: false, | ||
locale: false, | ||
key: '/710c8209d70454012a0cacef5e4c67ef9c6f40ed7b56311cd60545bd50437341', | ||
routes: null, | ||
pro_layout_parentKeys: [], | ||
}, | ||
{ | ||
path: '/bkmng/authority', | ||
name: '我的权限', | ||
routes: null, | ||
children: [ | ||
{ | ||
path: '/bkmng/authority/my', | ||
name: '权限列表', | ||
routes: null, | ||
unaccessible: false, | ||
locale: 'menu.我的权限.权限列表', | ||
key: '/yfd/bkmng/authority/my', | ||
exact: true, | ||
pro_layout_parentKeys: ['/yfd/bkmng/authority'], | ||
}, | ||
{ | ||
path: '/bkmng/authority/apply', | ||
name: '申请权限', | ||
routes: null, | ||
unaccessible: false, | ||
locale: 'menu.我的权限.申请权限', | ||
key: '/yfd/bkmng/authority/apply', | ||
exact: true, | ||
pro_layout_parentKeys: ['/yfd/bkmng/authority'], | ||
}, | ||
], | ||
unaccessible: false, | ||
locale: 'menu.我的权限', | ||
key: '/yfd/bkmng/authority', | ||
pro_layout_parentKeys: [], | ||
}, | ||
{ | ||
path: '/bkmng', | ||
yunfengdieApp: '21704052', | ||
exact: false, | ||
unaccessible: false, | ||
locale: false, | ||
key: '/bkmng', | ||
routes: null, | ||
pro_layout_parentKeys: [], | ||
}, | ||
]); | ||
expect(openMenuItems.length).toBe(1); | ||
expect(openMenuItems[0].path).toBe('/bkmng/authority/my'); | ||
expect(openMenuItems).toMatchSnapshot(); | ||
}); | ||
//# sourceMappingURL=getMatchMenu.test.js.map |
@@ -43,6 +43,3 @@ import isEqual from 'lodash.isequal'; | ||
// 如果配置了 locale 并且 locale 为 false或 "" | ||
if ('locale' in item && !locale) { | ||
return ''; | ||
} | ||
if (!name || locale === false) { | ||
if (('locale' in item && locale === false) || !name) { | ||
return false; | ||
@@ -49,0 +46,0 @@ } |
@@ -20,3 +20,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
menus[item.key || item.path || '/'] = _objectSpread({}, item); | ||
if (item.path !== '/') { | ||
menus[item.path || item.key || '/'] = _objectSpread({}, item); | ||
} else { | ||
menus[item.key || item.path || '/'] = _objectSpread({}, item); | ||
} | ||
@@ -23,0 +27,0 @@ if (item.children) { |
@@ -111,7 +111,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
if ('locale' in item && !locale) { | ||
return ''; | ||
} | ||
if (!name || locale === false) { | ||
if ('locale' in item && locale === false || !name) { | ||
return false; | ||
@@ -118,0 +114,0 @@ } |
@@ -27,3 +27,7 @@ "use strict"; | ||
menus[item.key || item.path || '/'] = _objectSpread({}, item); | ||
if (item.path !== '/') { | ||
menus[item.path || item.key || '/'] = _objectSpread({}, item); | ||
} else { | ||
menus[item.key || item.path || '/'] = _objectSpread({}, item); | ||
} | ||
@@ -30,0 +34,0 @@ if (item.children) { |
@@ -132,7 +132,3 @@ "use strict"; | ||
if ('locale' in item && !locale) { | ||
return ''; | ||
} | ||
if (!name || locale === false) { | ||
if ('locale' in item && locale === false || !name) { | ||
return false; | ||
@@ -139,0 +135,0 @@ } |
{ | ||
"name": "@umijs/route-utils", | ||
"version": "1.0.25", | ||
"version": "1.0.26", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
323370
3827