From 9a895763d55e147be355a2198ecfd33f66c2e746 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期二, 23 八月 2022 20:59:26 +0800 Subject: [PATCH] 优化页面内嵌iframe切换tab不刷新数据 --- ruoyi-ui/src/store/modules/tagsView.js | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ruoyi-ui/src/store/modules/tagsView.js b/ruoyi-ui/src/store/modules/tagsView.js index 39c70cb..9a88c2b 100644 --- a/ruoyi-ui/src/store/modules/tagsView.js +++ b/ruoyi-ui/src/store/modules/tagsView.js @@ -6,11 +6,12 @@ const mutations = { ADD_IFRAME_VIEW: (state, view) => { - if (state.iframeViews.some(v => v.path === view.path)) { - return - } else { - state.iframeViews.push(view) - } + if (state.iframeViews.some(v => v.path === view.path)) return + state.iframeViews.push( + Object.assign({}, view, { + title: view.meta.title || 'no-name' + }) + ) }, ADD_VISITED_VIEW: (state, view) => { if (state.visitedViews.some(v => v.path === view.path)) return @@ -87,10 +88,12 @@ if (i > -1) { state.cachedViews.splice(i, 1) } + if(item.meta.link) { + const fi = state.iframeViews.findIndex(v => v.path === item.path) + state.iframeViews.splice(fi, 1) + } return false }) - const iframeIndex = state.iframeViews.findIndex(v => v.path === view.path) - state.iframeViews = state.iframeViews.filter((item, idx) => idx <= iframeIndex) }, DEL_LEFT_VIEWS: (state, view) => { const index = state.visitedViews.findIndex(v => v.path === view.path) @@ -105,10 +108,12 @@ if (i > -1) { state.cachedViews.splice(i, 1) } + if(item.meta.link) { + const fi = state.iframeViews.findIndex(v => v.path === item.path) + state.iframeViews.splice(fi, 1) + } return false }) - const iframeIndex = state.iframeViews.findIndex(v => v.path === view.path) - state.iframeViews = state.iframeViews.filter((item, idx) => idx >= iframeIndex) } } -- Gitblit v1.9.2