From 51636e9cd814bddba7a9b4ff21b5bc94e95fb6cb Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期二, 14 五月 2024 09:21:36 +0800
Subject: [PATCH] 配置文档

---
 Source/ProjectWeb/src/router/avue-router.js |   42 ++++++++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/Source/ProjectWeb/src/router/avue-router.js b/Source/ProjectWeb/src/router/avue-router.js
index 933f2a5..52c14c9 100644
--- a/Source/ProjectWeb/src/router/avue-router.js
+++ b/Source/ProjectWeb/src/router/avue-router.js
@@ -1,3 +1,5 @@
+import {validatenull} from "@/util/validate";
+
 let RouterPlugin = function () {
   this.$router = null;
   this.$store = null;
@@ -90,7 +92,6 @@
      * first: 涓轰簡鍖哄垎澶栫晫 璋冪敤formatRoutes 鍜� 褰撳墠鏂囦欢璋冪敤 formatRoutes
      */
     formatRoutes: function (aMenu = [], first) {
-      // debugger;
       const aRouter = []
       // 鑾峰彇鍒板叏灞�閰嶇疆涓殑 props
       const propsConfig = this.$website.menu.props;
@@ -98,7 +99,8 @@
       const propsDefault = {
         label: propsConfig.label || 'name',
         path: 'code',
-        pathValue:propsConfig.path || 'path',
+        code: 'code',
+        pathValue: 'pathValue',
         icon: propsConfig.icon || 'icon',
         children: propsConfig.children || 'children',
         meta: propsConfig.meta || 'meta',
@@ -119,20 +121,32 @@
           }
         })();
         let code = (() => {
-            return oMenu[propsDefault.path]
+          return oMenu[propsDefault.code]
         })();
-        // 灏嗗瓧绗︿覆鍒嗗壊鎴愭暟缁勶紝浠�'?'浣滀负鍒嗛殧绗�
-        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";
+        let component = '';
+        let parts = '';
+
+        // 濡傛灉璺緞涓瓨鍦� '?'锛屽垯鍙栭棶鍙峰墠闈㈤儴鍒嗙粰 parts
+        if (path.includes('?')) {
+          parts = path.split("?")[0];
+        } else {
+          parts = path; // 涓嶅瓨鍦� '?' 鏁存潯璺緞灏辨槸 parts
+        }
+        if(validatenull(parts)){
+          parts='UI';
+        }
+        // 濡傛灉闂彿鍓嶉潰閮ㄥ垎涓嶅湪 ['ui', 'UI', 'base'] 涓紝鍒欐槸鑷畾涔夌粍浠�
+        if (!['ui', 'UI', 'base','bs'].includes(parts) && parts.indexOf('views/')==-1) {
+          component = `views/custom-ui/${parts}`;
+        }else if (['UI', 'ui', 'base','bs'].includes(parts)) {
+          // 濡傛灉闂彿鍓嶉潰绛変簬 UI銆乽i 鍒欎负UI寮曟搸
+          component = 'views/base/UIContentViewer';
+        }else{
+          component = `${parts}`;
         }
 
-        //鐗规畩澶勭悊缁勪欢 鎵ц瀹岃繖涓� component 涔熷氨鏄簿纭埌鍏蜂綋鐨勬枃浠朵簡  views鏂囦欢澶逛笅闈㈠氨鏄叿浣撶殑椤甸潰浠g爜
-        let component = bsValue === 'UI' ? 'views/base/UIContentViewer' : `views/custom-ui/${bsValue}`,
-          name = oMenu[propsDefault.label],
+        let name = oMenu[propsDefault.label],
           icon = oMenu[propsDefault.icon],
           children = oMenu[propsDefault.children],
           meta = oMenu[propsDefault.meta] || {};
@@ -147,7 +161,7 @@
         //鏄惁鏈夊瓙璺敱
         const isChild = children.length !== 0;
         const oRouter = {
-          path: code,
+          path: '/' + code,
           component(resolve) {
             // 鍒ゆ柇鏄惁涓洪璺敱
             if (first) {
@@ -175,7 +189,7 @@
           children: !isChild ? (() => {
             if (first) {
               // 杩欓噷鐨刬sURL鍒ゆ柇锛屽洜涓鸿繖涓綉绔欐湁浣跨敤 iframe銆傛墍浠ラ渶瑕佸垽鏂槸鍚︿负缃戦〉閾炬帴
-              if (!isURL(path)) oMenu[propsDefault.path] = `${path}/index`;
+              if (!isURL(path)) oMenu[propsDefault.pathValue] = `${path}/index`;
               return [{
                 component(resolve) {
                   require([`../${component}.vue`], resolve)

--
Gitblit v1.9.3