From 2ac55ce0edf4870a29691b56bfad59f4830a11a2 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期日, 07 四月 2024 16:52:18 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/ProjectWeb/src/router/avue-router.js | 52 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 32 insertions(+), 20 deletions(-) diff --git a/Source/ProjectWeb/src/router/avue-router.js b/Source/ProjectWeb/src/router/avue-router.js index 0e68bda..933f2a5 100644 --- a/Source/ProjectWeb/src/router/avue-router.js +++ b/Source/ProjectWeb/src/router/avue-router.js @@ -6,7 +6,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,20 +85,20 @@ }, //鍔ㄦ�佽矾鐢� // 璺敱鏄笓闂ㄧ殑涓�涓帴鍙h幏鍙� - /** - * aMenu: 鎺ュ彈鍒扮殑鍔ㄦ�佽矾鐢辨暟鎹� menu鐨勭粨鏋勫灞傛湁鐖剁骇path 閲岄潰鏈変竴涓猚hilden 璁板綍椤甸潰鐨勮矾鐢� - * first: 涓轰簡鍖哄垎澶栫晫 璋冪敤formatRoutes 鍜� 褰撳墠鏂囦欢璋冪敤 formatRoutes - */ + /** + * aMenu: 鎺ュ彈鍒扮殑鍔ㄦ�佽矾鐢辨暟鎹� menu鐨勭粨鏋勫灞傛湁鐖剁骇path 閲岄潰鏈変竴涓猚hilden 璁板綍椤甸潰鐨勮矾鐢� + * first: 涓轰簡鍖哄垎澶栫晫 璋冪敤formatRoutes 鍜� 褰撳墠鏂囦欢璋冪敤 formatRoutes + */ formatRoutes: function (aMenu = [], first) { - // window.console.log('aMenu') - // window.console.log(aMenu) + // debugger; const aRouter = [] // 鑾峰彇鍒板叏灞�閰嶇疆涓殑 props const propsConfig = this.$website.menu.props; // 璁剧疆 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', @@ -111,20 +111,32 @@ 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, + if (first) { + // 灏� '/index' 鏇挎崲涓� '' + return oMenu[propsDefault.pathValue].replace('/index', '') + } else { + 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鏂囦欢澶逛笅闈㈠氨鏄叿浣撶殑椤甸潰浠g爜 + let component = bsValue === 'UI' ? 'views/base/UIContentViewer' : `views/custom-ui/${bsValue}`, 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 +147,7 @@ //鏄惁鏈夊瓙璺敱 const isChild = children.length !== 0; const oRouter = { - path: path, + path: code, component(resolve) { // 鍒ゆ柇鏄惁涓洪璺敱 if (first) { @@ -179,7 +191,7 @@ /** * 杩欓噷鏄噸鐐癸紝褰撴湁瀛愯矾鐢辩殑鏃跺�� 浼氬啀鍘绘墽琛� formatRoutes 鏂规硶锛岀劧鍚庡張浼氭湁涓�涓柊鐨� aMenu for寰幆銆� * 鏈�鍚庤繑鍥炵殑鏄竴涓暟缁� aRouter 杩欎釜鏁扮粍灏变細浣滀负 childen鐨勫�艰 return - */ + */ return this.formatRoutes(children, false) })() } -- Gitblit v1.9.3