作者 RuoYi

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

@@ -20,6 +20,11 @@ public class Constants @@ -20,6 +20,11 @@ public class Constants
20 public static final String GBK = "GBK"; 20 public static final String GBK = "GBK";
21 21
22 /** 22 /**
  23 + * www主域
  24 + */
  25 + public static final String WWW = "www.";
  26 +
  27 + /**
23 * http请求 28 * http请求
24 */ 29 */
25 public static final String HTTP = "http://"; 30 public static final String HTTP = "http://";
@@ -529,7 +529,7 @@ public class SysMenuServiceImpl implements ISysMenuService @@ -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 }
@@ -6,11 +6,12 @@ const state = { @@ -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,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,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