This commit is contained in:
lcw
2025-12-05 21:36:34 +08:00
parent 64ab9fc44c
commit b39387c4ed
97 changed files with 3342 additions and 298 deletions

View File

@ -21,7 +21,7 @@ export default {
state.routes = [...publicRoutes, ...newRoutes]
},
setRouteReady(state, num) {
state.routeReady = state.routeReady + num;
state.routeReady = num;
},
resetrouteReady(state) {
state.routeReady = 0
@ -36,26 +36,24 @@ export default {
*/
filterRoutes(context, menus) {
let routes = []
// 路由权限匹配
// menus.forEach(key => {
// // 权限名 与 路由的 name 匹配
// routes.push(...privateRoutes.filter(item => item.name === key))
// })
/**
* 树结构数据条件过滤
* js 指定删除数组(树结构数据)
* 根据用户权限筛选出可访问的路由
*/
//测试比对
// routes = filter(privateRoutes, menus)
if (menus && menus.length > 0) {
routes = filter(privateRoutes, menus)
}
// 最后添加 不匹配路由进入 404
routes.push({
path: '/:catchAll(.*)',
redirect: '/404'
})
context.commit('setRoutes', routes);
context.commit('setRouteReady', 1);
// context.commit('setRouteReady', true);
return routes
}
}