Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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.32 to 1.0.33

4

dist/getMatchMenu/getMatchMenu.d.ts
import { MenuDataItem } from '../types';
export declare const getMenuMatches: (flatMenuKeys: string[] | undefined, path: string) => string | undefined;
export declare const getMenuMatches: (flatMenuKeys: string[] | undefined, path: string) => string[] | undefined;
/**

@@ -9,3 +9,3 @@ * 获取当前的选中菜单列表

*/
export declare const getMatchMenu: (pathname: string, menuData: MenuDataItem[]) => MenuDataItem[];
export declare const getMatchMenu: (pathname: string, menuData: MenuDataItem[], fullKeys?: boolean | undefined) => MenuDataItem[];
export default getMatchMenu;

@@ -36,4 +36,3 @@ import { pathToRegexp } from '@qixian.cs/path-to-regexp';

return a.substr(1).split('/').length - b.substr(1).split('/').length;
})
.pop();
});
/**

@@ -45,30 +44,41 @@ * 获取当前的选中菜单列表

*/
export const getMatchMenu = (pathname, menuData) => {
export const getMatchMenu = (pathname, menuData,
/**
* 要不要展示全部的 key
*/
fullKeys) => {
const flatMenus = getFlatMenu(menuData);
const flatMenuKeys = Object.keys(flatMenus);
const menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/');
if (!menuPathKey) {
let menuPathKeys = getMenuMatches(flatMenuKeys, pathname || '/');
if (!menuPathKeys || menuPathKeys.length < 1) {
return [];
}
const menuItem = flatMenus[menuPathKey] || {
pro_layout_parentKeys: '',
key: '',
};
// 去重
const map = new Map();
const parentItems = (menuItem.pro_layout_parentKeys || [])
.map((key) => {
if (map.has(key)) {
return null;
if (!fullKeys) {
menuPathKeys = [menuPathKeys[menuPathKeys.length - 1]];
}
return menuPathKeys
.map((menuPathKey) => {
const menuItem = flatMenus[menuPathKey] || {
pro_layout_parentKeys: '',
key: '',
};
// 去重
const map = new Map();
const parentItems = (menuItem.pro_layout_parentKeys || [])
.map((key) => {
if (map.has(key)) {
return null;
}
map.set(key, true);
return flatMenus[key];
})
.filter((item) => item);
if (menuItem.key) {
parentItems.push(menuItem);
}
map.set(key, true);
return flatMenus[key];
return parentItems;
})
.filter((item) => item);
if (menuItem.key) {
parentItems.push(menuItem);
}
return parentItems;
.flat(1);
};
export default getMatchMenu;
//# sourceMappingURL=getMatchMenu.js.map

@@ -41,3 +41,3 @@ import { pathToRegexp } from '@qixian.cs/path-to-regexp';

return a.substr(1).split('/').length - b.substr(1).split('/').length;
}).pop();
});
};

@@ -51,34 +51,44 @@ /**

export var getMatchMenu = function getMatchMenu(pathname, menuData) {
export var getMatchMenu = function getMatchMenu(pathname, menuData,
/**
* 要不要展示全部的 key
*/
fullKeys) {
var flatMenus = getFlatMenu(menuData);
var flatMenuKeys = Object.keys(flatMenus);
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/');
var menuPathKeys = getMenuMatches(flatMenuKeys, pathname || '/');
if (!menuPathKey) {
if (!menuPathKeys || menuPathKeys.length < 1) {
return [];
}
var menuItem = flatMenus[menuPathKey] || {
pro_layout_parentKeys: '',
key: ''
}; // 去重
if (!fullKeys) {
menuPathKeys = [menuPathKeys[menuPathKeys.length - 1]];
}
var map = new Map();
var parentItems = (menuItem.pro_layout_parentKeys || []).map(function (key) {
if (map.has(key)) {
return null;
}
return menuPathKeys.map(function (menuPathKey) {
var menuItem = flatMenus[menuPathKey] || {
pro_layout_parentKeys: '',
key: ''
}; // 去重
map.set(key, true);
return flatMenus[key];
}).filter(function (item) {
return item;
});
var map = new Map();
var parentItems = (menuItem.pro_layout_parentKeys || []).map(function (key) {
if (map.has(key)) {
return null;
}
if (menuItem.key) {
parentItems.push(menuItem);
}
map.set(key, true);
return flatMenus[key];
}).filter(function (item) {
return item;
});
return parentItems;
if (menuItem.key) {
parentItems.push(menuItem);
}
return parentItems;
}).flat(1);
};
export default getMatchMenu;

@@ -53,3 +53,3 @@ "use strict";

return a.substr(1).split('/').length - b.substr(1).split('/').length;
}).pop();
});
};

@@ -66,33 +66,43 @@ /**

var getMatchMenu = function getMatchMenu(pathname, menuData) {
var getMatchMenu = function getMatchMenu(pathname, menuData,
/**
* 要不要展示全部的 key
*/
fullKeys) {
var flatMenus = (0, _getFlatMenus.default)(menuData);
var flatMenuKeys = Object.keys(flatMenus);
var menuPathKey = getMenuMatches(flatMenuKeys, pathname || '/');
var menuPathKeys = getMenuMatches(flatMenuKeys, pathname || '/');
if (!menuPathKey) {
if (!menuPathKeys || menuPathKeys.length < 1) {
return [];
}
var menuItem = flatMenus[menuPathKey] || {
pro_layout_parentKeys: '',
key: ''
}; // 去重
if (!fullKeys) {
menuPathKeys = [menuPathKeys[menuPathKeys.length - 1]];
}
var map = new Map();
var parentItems = (menuItem.pro_layout_parentKeys || []).map(function (key) {
if (map.has(key)) {
return null;
}
return menuPathKeys.map(function (menuPathKey) {
var menuItem = flatMenus[menuPathKey] || {
pro_layout_parentKeys: '',
key: ''
}; // 去重
map.set(key, true);
return flatMenus[key];
}).filter(function (item) {
return item;
});
var map = new Map();
var parentItems = (menuItem.pro_layout_parentKeys || []).map(function (key) {
if (map.has(key)) {
return null;
}
if (menuItem.key) {
parentItems.push(menuItem);
}
map.set(key, true);
return flatMenus[key];
}).filter(function (item) {
return item;
});
return parentItems;
if (menuItem.key) {
parentItems.push(menuItem);
}
return parentItems;
}).flat(1);
};

@@ -99,0 +109,0 @@

{
"name": "@umijs/route-utils",
"version": "1.0.32",
"version": "1.0.33",
"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

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