田源
2024-04-07 0ba9e571a77dab21c749461c298af1bca69b6b98
Source/ProjectWeb/src/router/avue-router.js
@@ -97,7 +97,8 @@
      // 设置 props默认值 作用就是将字段设置成配置的
      const propsDefault = {
        label: propsConfig.label || 'name',
        path: propsConfig.path || 'path',
        path: 'code',
        pathValue:propsConfig.path || 'path',
        icon: propsConfig.icon || 'icon',
        children: propsConfig.children || 'children',
        meta: propsConfig.meta || 'meta',
@@ -112,13 +113,25 @@
        let path = (() => {
            if (first) {
              // 将 '/index' 替换为 ''
              return oMenu[propsDefault.path].replace('/index', '')
            return oMenu[propsDefault.pathValue].replace('/index', '')
            } else {
              return oMenu[propsDefault.path]
            return oMenu[propsDefault.pathValue]
            }
          })(),
        })();
        let code = (() => {
            return oMenu[propsDefault.path]
        })();
        // 将字符串分割成数组,以'?'作为分隔符
        let parts = path.split("?");
        // 如果数组的长度大于1,表示有'?',则取第一个元素的第一个部分,否则直接取整个字符串
        let bsValue = parts.length > 1 ? parts[0].split("=")[1] : path.split("=")[1];
        if (bsValue ===''  || bsValue === undefined || bsValue === null ) {
          bsValue = "UI";
        }
          //特殊处理组件 执行完这个 component 也就是精确到具体的文件了  views文件夹下面就是具体的页面代码
          component = 'views' + path,
        let component = bsValue === 'UI' ? 'views/base/UIContentViewer' : `views/custom-ui/${bsValue}`,
          name = oMenu[propsDefault.label],
          icon = oMenu[propsDefault.icon],
          children = oMenu[propsDefault.children],
@@ -134,7 +147,7 @@
        //是否有子路由
        const isChild = children.length !== 0;
        const oRouter = {
          path: path,
          path: code,
          component(resolve) {
            // 判断是否为首路由
            if (first) {