UNPKG

guci-date

Version:

A golden bottle of sake costs ten thousand yuan, and a jade plate costs ten thousand yuan.

29 lines (27 loc) 796 B
/* * {array} userRouter 后端返回的路由权限 *{array} allRouter 前端配置好的路由权限 * realRoutes 过滤后的路由 * */ export function recursionRouter(userRouter = [], allRouter = []) { var realRoutes = []; allRouter.forEach((v, i) => { userRouter.forEach((item, index) => { if (item.jurTitle === v.meta.name) { if (item.children && item.children.length > 0) { v.children = recursionRouter(item.children, v.children); } realRoutes.push(v) } }) }) return realRoutes; } export function setDefaultRoute(routes) { routes.forEach((v, i) => { if (v.children && v.children.length > 0) { v.redirect = {name: caches.children[0].naem} setDefaultRoute(v.children); } }) }