Socket
Socket
Sign inDemoInstall

@umijs/route-utils

Package Overview
Dependencies
Maintainers
14
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@umijs/route-utils - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

6

dist/getFlatMenus/getFlatMenus.js

@@ -9,7 +9,7 @@ /**

menuData.forEach(item => {
if (!item || item.hideInMenu || !item.key) {
if (!item || !item.key) {
return;
}
menus[item.path || '/'] = { ...item };
if (item.children && !item.hideChildrenInMenu) {
menus[item.key || item.path || '/'] = { ...item };
if (item.children) {
menus = { ...menus, ...getFlatMenus(item.children) };

@@ -16,0 +16,0 @@ }

@@ -69,4 +69,12 @@ import pathToRegexp from 'path-to-regexp';

};
// 去重
const map = new Map();
const parentItems = (menuItem.pro_layout_parentKeys || [])
.map(key => flatMenus[key])
.map(key => {
if (map.has(key)) {
return null;
}
map.set(key, true);
return flatMenus[key];
})
.filter(item => item);

@@ -73,0 +81,0 @@ if (menuItem.key) {

@@ -48,2 +48,95 @@ import getMatchMenu from './getMatchMenu';

];
const layout_Router_config = [
{
path: 'https://github.com/ant-design/ant-design-pro-layout/issues',
name: 'site',
icon: 'smile',
locale: false,
target: '_blank',
component: './Welcome',
},
{
name: 'flex 布局测试',
icon: 'smile',
path: 'flex',
component: './FlexDemo',
},
{
name: '分析页',
icon: 'smile',
path: '/dashboardanalysis',
component: './DashboardAnalysisTwo',
},
{
name: '个人设置',
icon: 'smile',
path: '/accountsettings',
component: './AccountSettings',
},
{
name: '高级表单',
icon: 'smile',
path: 'formadvancedform',
component: './FormAdvancedForm',
},
{
path: 'single',
name: 'Single',
routes: [
{
path: 'welcome',
name: 'two',
icon: 'smile',
component: './Welcome',
},
{
path: 'welcome2',
name: 'two2',
icon: 'smile',
component: './Welcome',
},
{
path: 'welcome3/:id?',
name: 'two3',
hideInMenu: true,
icon: 'smile',
component: './Welcome',
},
],
},
{
path: '/',
name: 'welcome',
icon: 'smile',
routes: [
{
path: '/',
redirect: '/welcome',
},
{
path: '/welcome',
redirect: '/welcome/welcome',
},
{
path: 'welcome',
name: 'one',
component: './Welcome',
routes: [
{
path: 'repertoryFw',
name: 'two',
icon: 'smile',
component: './Welcome',
},
{
path: 'repertory',
name: 'two2',
icon: 'smile',
component: './Welcome',
},
],
},
],
},
];
const { menuData } = transformRoute(routes, true, ({ id }) => {

@@ -110,2 +203,8 @@ if (id === 'menu.list.table-list')

});
test('test_layout_router', () => {
const { menuData: userMenuData } = transformRoute(layout_Router_config, false);
const openMenuItems = getMatchMenu('/welcome/repertoryFw', userMenuData);
expect(openMenuItems.length).toEqual(3);
expect(openMenuItems).toMatchSnapshot();
});
//# sourceMappingURL=getMatchMenu.test.js.map

@@ -17,16 +17,12 @@ import isEqual from 'lodash.isequal';

export const getKeyByPath = (item) => {
const { path, name } = item;
const { path } = item;
if (path && path !== '/') {
return path;
}
// 如果有name, 使用name
if (name) {
return name;
}
// 如果还是没有,用对象的hash 生成一个
try {
return hash
return `/${hash
.sha256()
.update(JSON.stringify(item))
.digest('hex');
.digest('hex')}`;
}

@@ -168,3 +164,3 @@ catch (error) {

locale,
key: item.key || getKeyByPath(item),
key: item.key || getKeyByPath({ ...item, path }),
routes: null,

@@ -171,0 +167,0 @@ pro_layout_parentKeys: [

@@ -129,2 +129,106 @@ import transformRoute from './transformRoute';

});
const layout_Router_config = [
{
path: '/',
component: '../layouts/BasicLayout',
routes: [
{
path: 'https://github.com/ant-design/ant-design-pro-layout/issues',
name: 'site',
icon: 'smile',
locale: false,
target: '_blank',
component: './Welcome',
},
{
name: 'flex 布局测试',
icon: 'smile',
path: 'flex',
component: './FlexDemo',
},
{
name: '分析页',
icon: 'smile',
path: '/dashboardanalysis',
component: './DashboardAnalysisTwo',
},
{
name: '个人设置',
icon: 'smile',
path: '/accountsettings',
component: './AccountSettings',
},
{
name: '高级表单',
icon: 'smile',
path: 'formadvancedform',
component: './FormAdvancedForm',
},
{
path: 'single',
name: 'Single',
routes: [
{
path: 'welcome',
name: 'two',
icon: 'smile',
component: './Welcome',
},
{
path: 'welcome2',
name: 'two2',
icon: 'smile',
component: './Welcome',
},
{
path: 'welcome3/:id?',
name: 'two3',
hideInMenu: true,
icon: 'smile',
component: './Welcome',
},
],
},
{
path: '/',
name: 'welcome',
icon: 'smile',
routes: [
{
path: '/',
redirect: '/welcome',
},
{
path: '/welcome',
redirect: '/welcome/welcome',
},
{
path: 'welcome',
name: 'one',
component: './Welcome',
routes: [
{
path: 'repertoryFw',
name: 'two',
icon: 'smile',
component: './Welcome',
},
{
path: 'repertory',
name: 'two2',
icon: 'smile',
component: './Welcome',
},
],
},
],
},
],
},
];
test('layout Router config with "/"', () => {
const { menuData: userMenuData, breadcrumb } = transformRoute(layout_Router_config, false);
expect(userMenuData).toMatchSnapshot();
expect(breadcrumb).toMatchSnapshot();
});
//# sourceMappingURL=transformRoute.test.js.map

@@ -16,9 +16,9 @@ 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; }

menuData.forEach(function (item) {
if (!item || item.hideInMenu || !item.key) {
if (!item || !item.key) {
return;
}
menus[item.path || '/'] = _objectSpread({}, item);
menus[item.key || item.path || '/'] = _objectSpread({}, item);
if (item.children && !item.hideChildrenInMenu) {
if (item.children) {
menus = _objectSpread(_objectSpread({}, menus), getFlatMenus(item.children));

@@ -25,0 +25,0 @@ }

@@ -79,4 +79,11 @@ import pathToRegexp from 'path-to-regexp';

key: ''
};
}; // 去重
var map = new Map();
var parentItems = (menuItem.pro_layout_parentKeys || []).map(function (key) {
if (map.has(key)) {
return null;
}
map.set(key, true);
return flatMenus[key];

@@ -83,0 +90,0 @@ }).filter(function (item) {

@@ -42,12 +42,6 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

export var getKeyByPath = function getKeyByPath(item) {
var path = item.path,
name = item.name;
var path = item.path;
if (path && path !== '/') {
return path;
} // 如果有name, 使用name
if (name) {
return name;
} // 如果还是没有,用对象的hash 生成一个

@@ -57,3 +51,3 @@

try {
return hash.sha256().update(JSON.stringify(item)).digest('hex');
return "/".concat(hash.sha256().update(JSON.stringify(item)).digest('hex'));
} catch (error) {} // dom some thing

@@ -236,3 +230,5 @@ // 要是还是不行,返回一个随机值

locale: locale,
key: item.key || getKeyByPath(item),
key: item.key || getKeyByPath(_objectSpread(_objectSpread({}, item), {}, {
path: path
})),
routes: null,

@@ -239,0 +235,0 @@ pro_layout_parentKeys: [].concat(_toConsumableArray(pro_layout_parentKeys), ["/".concat(parent.key || '').replace(/\/\//g, '/').replace(/\/\//g, '/')]).filter(function (key) {

@@ -23,9 +23,9 @@ "use strict";

menuData.forEach(function (item) {
if (!item || item.hideInMenu || !item.key) {
if (!item || !item.key) {
return;
}
menus[item.path || '/'] = _objectSpread({}, item);
menus[item.key || item.path || '/'] = _objectSpread({}, item);
if (item.children && !item.hideChildrenInMenu) {
if (item.children) {
menus = _objectSpread(_objectSpread({}, menus), getFlatMenus(item.children));

@@ -32,0 +32,0 @@ }

@@ -95,4 +95,11 @@ "use strict";

key: ''
};
}; // 去重
var map = new Map();
var parentItems = (menuItem.pro_layout_parentKeys || []).map(function (key) {
if (map.has(key)) {
return null;
}
map.set(key, true);
return flatMenus[key];

@@ -99,0 +106,0 @@ }).filter(function (item) {

@@ -59,12 +59,6 @@ "use strict";

var getKeyByPath = function getKeyByPath(item) {
var path = item.path,
name = item.name;
var path = item.path;
if (path && path !== '/') {
return path;
} // 如果有name, 使用name
if (name) {
return name;
} // 如果还是没有,用对象的hash 生成一个

@@ -74,3 +68,3 @@

try {
return _hash.default.sha256().update(JSON.stringify(item)).digest('hex');
return "/".concat(_hash.default.sha256().update(JSON.stringify(item)).digest('hex'));
} catch (error) {} // dom some thing

@@ -256,3 +250,5 @@ // 要是还是不行,返回一个随机值

locale: locale,
key: item.key || getKeyByPath(item),
key: item.key || getKeyByPath(_objectSpread(_objectSpread({}, item), {}, {
path: path
})),
routes: null,

@@ -259,0 +255,0 @@ pro_layout_parentKeys: [].concat(_toConsumableArray(pro_layout_parentKeys), ["/".concat(parent.key || '').replace(/\/\//g, '/').replace(/\/\//g, '/')]).filter(function (key) {

{
"name": "@umijs/route-utils",
"version": "1.0.15",
"version": "1.0.16",
"description": "Quickly process the routing of umi",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -1,2 +0,2 @@

# @umi-material/@umijs/route-utils
# @umijs/route-utils

@@ -19,3 +19,2 @@ ## Usage

getMatchMenu,
getMatchMenu,
} from ' @umijs/route-utils';

@@ -22,0 +21,0 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc