Преглед изворни кода

优化页面内嵌iframe切换tab不刷新数据

RuoYi пре 3 година
родитељ
комит
52d50e4e47

+ 5 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java

@@ -18,6 +18,11 @@ public class Constants
18
     public static final String GBK = "GBK";
18
     public static final String GBK = "GBK";
19
 
19
 
20
     /**
20
     /**
21
+     * www主域
22
+     */
23
+    public static final String WWW = "www.";
24
+
25
+    /**
21
      * RMI 远程方法调用
26
      * RMI 远程方法调用
22
      */
27
      */
23
     public static final String LOOKUP_RMI = "rmi:";
28
     public static final String LOOKUP_RMI = "rmi:";

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java

@@ -529,7 +529,7 @@ public class SysMenuServiceImpl implements ISysMenuService
529
      */
529
      */
530
     public String innerLinkReplaceEach(String path)
530
     public String innerLinkReplaceEach(String path)
531
     {
531
     {
532
-        return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS },
533
-                new String[] { "", "" });
532
+        return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, "." },
533
+                new String[] { "", "", "", "/" });
534
     }
534
     }
535
 }
535
 }

+ 14 - 9
ruoyi-ui/src/store/modules/tagsView.js

@@ -6,11 +6,12 @@ const state = {
6
 
6
 
7
 const mutations = {
7
 const mutations = {
8
   ADD_IFRAME_VIEW: (state, view) => {
8
   ADD_IFRAME_VIEW: (state, view) => {
9
-    if (state.iframeViews.some(v => v.path === view.path)) {
10
-      return
11
-    } else {
12
-      state.iframeViews.push(view)
13
-    }
9
+    if (state.iframeViews.some(v => v.path === view.path)) return
10
+    state.iframeViews.push(
11
+      Object.assign({}, view, {
12
+        title: view.meta.title || 'no-name'
13
+      })
14
+    )
14
   },
15
   },
15
   ADD_VISITED_VIEW: (state, view) => {
16
   ADD_VISITED_VIEW: (state, view) => {
16
     if (state.visitedViews.some(v => v.path === view.path)) return
17
     if (state.visitedViews.some(v => v.path === view.path)) return
@@ -87,10 +88,12 @@ const mutations = {
87
       if (i > -1) {
88
       if (i > -1) {
88
         state.cachedViews.splice(i, 1)
89
         state.cachedViews.splice(i, 1)
89
       }
90
       }
91
+      if(item.meta.link) {
92
+        const fi = state.iframeViews.findIndex(v => v.path === item.path)
93
+        state.iframeViews.splice(fi, 1)
94
+      }
90
       return false
95
       return false
91
     })
96
     })
92
-    const iframeIndex = state.iframeViews.findIndex(v => v.path === view.path)
93
-    state.iframeViews = state.iframeViews.filter((item, idx) => idx <= iframeIndex)
94
   },
97
   },
95
   DEL_LEFT_VIEWS: (state, view) => {
98
   DEL_LEFT_VIEWS: (state, view) => {
96
     const index = state.visitedViews.findIndex(v => v.path === view.path)
99
     const index = state.visitedViews.findIndex(v => v.path === view.path)
@@ -105,10 +108,12 @@ const mutations = {
105
       if (i > -1) {
108
       if (i > -1) {
106
         state.cachedViews.splice(i, 1)
109
         state.cachedViews.splice(i, 1)
107
       }
110
       }
111
+      if(item.meta.link) {
112
+        const fi = state.iframeViews.findIndex(v => v.path === item.path)
113
+        state.iframeViews.splice(fi, 1)
114
+      }
108
       return false
115
       return false
109
     })
116
     })
110
-    const iframeIndex = state.iframeViews.findIndex(v => v.path === view.path)
111
-    state.iframeViews = state.iframeViews.filter((item, idx) => idx >= iframeIndex)
112
   }
117
   }
113
 }
118
 }
114
 
119