From a9bbbe822377536e6f3374b05e2b64b12b2f188c Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期一, 27 五月 2024 10:25:43 +0800
Subject: [PATCH] action文档

---
 Source/ProjectWeb/src/router/avue-router.js |   70 ++++++++++++++++++++++++-----------
 1 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/Source/ProjectWeb/src/router/avue-router.js b/Source/ProjectWeb/src/router/avue-router.js
index 1f5f0a7..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;
@@ -6,7 +8,7 @@
 RouterPlugin.install = function (vue, option = {}) {
   this.$router = option.router;
   this.$store = option.store;
-  this.$vue = new vue({ i18n: option.i18n });
+  this.$vue = new vue({i18n: option.i18n});
 
   // 杩欎釜鐨勪綔鐢ㄦ槸 涓轰簡妫�鏌ュ嚭缃戦〉閾炬帴锛屽洜涓烘湰椤圭洰鐢ㄥ埌浜� iframe
   function isURL(s) {
@@ -85,19 +87,20 @@
     },
     //鍔ㄦ�佽矾鐢�
     // 璺敱鏄笓闂ㄧ殑涓�涓帴鍙h幏鍙�
-      /**
-       * aMenu: 鎺ュ彈鍒扮殑鍔ㄦ�佽矾鐢辨暟鎹� menu鐨勭粨鏋勫灞傛湁鐖剁骇path 閲岄潰鏈変竴涓猚hilden 璁板綍椤甸潰鐨勮矾鐢�
-       * first: 涓轰簡鍖哄垎澶栫晫 璋冪敤formatRoutes 鍜� 褰撳墠鏂囦欢璋冪敤 formatRoutes
-      */
+    /**
+     * aMenu: 鎺ュ彈鍒扮殑鍔ㄦ�佽矾鐢辨暟鎹� menu鐨勭粨鏋勫灞傛湁鐖剁骇path 閲岄潰鏈変竴涓猚hilden 璁板綍椤甸潰鐨勮矾鐢�
+     * first: 涓轰簡鍖哄垎澶栫晫 璋冪敤formatRoutes 鍜� 褰撳墠鏂囦欢璋冪敤 formatRoutes
+     */
     formatRoutes: function (aMenu = [], first) {
-      debugger;
       const aRouter = []
       // 鑾峰彇鍒板叏灞�閰嶇疆涓殑 props
       const propsConfig = this.$website.menu.props;
       // 璁剧疆 props榛樿鍊� 浣滅敤灏辨槸灏嗗瓧娈佃缃垚閰嶇疆鐨�
       const propsDefault = {
         label: propsConfig.label || 'name',
-        path: propsConfig.path || 'path',
+        path: 'code',
+        code: 'code',
+        pathValue: 'pathValue',
         icon: propsConfig.icon || 'icon',
         children: propsConfig.children || 'children',
         meta: propsConfig.meta || 'meta',
@@ -110,21 +113,44 @@
         const oMenu = aMenu[i];
         // 杩欎竴鍧楃殑璧嬪�� 涔熷氨鏄彇鍒拌繑鍥炵殑鍊�
         let path = (() => {
-            if (first) {
-              // 灏� '/index' 鏇挎崲涓� ''
-              return oMenu[propsDefault.path].replace('/index', '')
-            } else {
-              return oMenu[propsDefault.path]
-            }
-          })(),
-          //鐗规畩澶勭悊缁勪欢 鎵ц瀹岃繖涓� component 涔熷氨鏄簿纭埌鍏蜂綋鐨勬枃浠朵簡  views鏂囦欢澶逛笅闈㈠氨鏄叿浣撶殑椤甸潰浠g爜
-          //component = 'views' + oMenu.path,
-          component =  oMenu.path,
-          name = oMenu[propsDefault.label],
+          if (first) {
+            // 灏� '/index' 鏇挎崲涓� ''
+            return oMenu[propsDefault.pathValue].replace('/index', '')
+          } else {
+            return oMenu[propsDefault.pathValue]
+          }
+        })();
+        let code = (() => {
+          return oMenu[propsDefault.code]
+        })();
+
+        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}`;
+        }
+
+        let name = oMenu[propsDefault.label],
           icon = oMenu[propsDefault.icon],
           children = oMenu[propsDefault.children],
           meta = oMenu[propsDefault.meta] || {};
-          // meta涓� keepalive 鐨勫鐞�
+        // meta涓� keepalive 鐨勫鐞�
         meta = Object.assign(meta, (function () {
           if (option.keepAlive === true) {
             return {
@@ -135,7 +161,7 @@
         //鏄惁鏈夊瓙璺敱
         const isChild = children.length !== 0;
         const oRouter = {
-          path: path,
+          path: '/' + code,
           component(resolve) {
             // 鍒ゆ柇鏄惁涓洪璺敱
             if (first) {
@@ -163,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)
@@ -179,7 +205,7 @@
             /**
              * 杩欓噷鏄噸鐐癸紝褰撴湁瀛愯矾鐢辩殑鏃跺�� 浼氬啀鍘绘墽琛� formatRoutes 鏂规硶锛岀劧鍚庡張浼氭湁涓�涓柊鐨� aMenu for寰幆銆�
              * 鏈�鍚庤繑鍥炵殑鏄竴涓暟缁� aRouter 杩欎釜鏁扮粍灏变細浣滀负 childen鐨勫�艰 return
-            */
+             */
             return this.formatRoutes(children, false)
           })()
         }

--
Gitblit v1.9.3