baoshiwei
2025-04-19 5d36e1f987ef21e44ded2e8a1d06c28094ec1e76
zhitan-vue/src/store/modules/permission.js
@@ -58,6 +58,20 @@
// 遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false, parentRoute = null) {
  return asyncRouterMap.filter(route => {
    // 不再过滤掉首页看板相关路由
    /*
    // 过滤掉首页看板相关路由
    if (route.name === 'Index' && route.meta && route.meta.title === '首页看板') {
      return false;
    }
    // 如果是首页看板的子菜单,也过滤掉
    if (route.path === '/index' || route.path === 'index' ||
        (route.meta && route.meta.title === '首页看板')) {
      return false;
    }
    */
    // 设置父路由引用
    if (parentRoute) {
      route.parent = parentRoute;
@@ -106,7 +120,18 @@
          // 设置父路由引用
          c.parent = el;
          
          c.path = el.path + '/' + c.path
          // 确保路径格式正确拼接
          if (el.path) {
            if (c.path.startsWith('/')) {
              // 绝对路径保持不变
              // 但也设置原始父路径用于菜单导航
              c.parentPath = el.path;
            } else {
              // 相对路径需要拼接
              c.path = el.path.endsWith('/') ? el.path + c.path : el.path + '/' + c.path;
            }
          }
          if (c.children && c.children.length) {
            children = children.concat(filterChildren(c.children, c))
            return
@@ -120,7 +145,18 @@
      // 设置父路由引用
      el.parent = lastRouter;
      
      el.path = lastRouter.path + '/' + el.path
      // 确保路径格式正确拼接
      if (lastRouter.path) {
        if (el.path.startsWith('/')) {
          // 绝对路径保持不变
          // 但也设置原始父路径用于菜单导航
          el.parentPath = lastRouter.path;
        } else {
          // 相对路径需要拼接
          el.path = lastRouter.path.endsWith('/') ? lastRouter.path + el.path : lastRouter.path + '/' + el.path;
        }
      }
      if (el.children && el.children.length) {
        children = children.concat(filterChildren(el.children, el))
        return