export { default as langUtil } from './langUtils'; export * from './requestUtil'; const USERID_KEY = 'userId'; export function getUserId() { return window.sessionStorage.getItem(USERID_KEY) || ''; } export function setUserId(val) { window.sessionStorage.setItem(USERID_KEY, val); } export function clearUserId() { window.sessionStorage.removeItem(USERID_KEY); } /** * 转变菜单列表为tree结构 * @param {Array} menuList 菜单列表 * @param {Boolean} filterMenu 是否过滤掉菜单,只保留目录 */ export function convertListToTree(menuList, filterMenu = false) { let tempMenu = [...menuList]; if (filterMenu) { tempMenu = tempMenu.filter(m => m.menuType !== 'MENU'); } for (const menu of menuList) { if (menu.parentMenuId === 0) continue; const parent = menuList.find(m => m.menuId === menu.parentMenuId); parent.children ? parent.children.push(menu) : (parent.children = [menu]); } return tempMenu.filter(m => m.parentMenuId === 0); } export function EMPTY_FUN() {} export const isFunction = val => typeof val === 'function';