diff --git a/src/layout/components/iframeView.vue b/src/layout/components/iframeView.vue new file mode 100644 index 00000000..3e64d542 --- /dev/null +++ b/src/layout/components/iframeView.vue @@ -0,0 +1,66 @@ + + + + + + + diff --git a/src/layout/components/tags.vue b/src/layout/components/tags.vue index 47918163..def8f930 100644 --- a/src/layout/components/tags.vue +++ b/src/layout/components/tags.vue @@ -119,6 +119,7 @@ //关闭tag closeSelectedTag(tag) { this.$store.commit("removeViewTags", tag) + this.$store.commit("removeIframeList", tag) this.$store.commit("removeKeepLive", tag.name) if (this.isActive(tag)) { const latestView = this.tagList.slice(-1)[0] @@ -151,6 +152,7 @@ path: nowTag.path }) } + this.$store.commit("refreshIframe", nowTag) var _this = this; setTimeout(function() { _this.$store.commit("removeKeepLive", nowTag.name) diff --git a/src/layout/index.vue b/src/layout/index.vue index beb44e05..2b8ad841 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -35,6 +35,7 @@
+
@@ -72,6 +73,7 @@
+
@@ -91,6 +93,7 @@ import NavMenu from './components/NavMenu.vue'; import userbar from './components/userbar.vue'; import setting from './components/setting.vue'; + import iframeView from './components/iframeView.vue'; export default { name: 'index', @@ -100,7 +103,8 @@ Tags, NavMenu, userbar, - setting + setting, + iframeView }, data() { return { diff --git a/src/router/index.js b/src/router/index.js index a0b2b656..ac3a2e7e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -82,7 +82,6 @@ function filterAsyncRouter(routerMap) { if(item.meta.type=='iframe'){ item.meta.url = item.path; item.path = `/i/${item.name}`; - item.component = 'other/iframe'; } //MAP转路由对象 var route = { diff --git a/src/store/modules/iframe.js b/src/store/modules/iframe.js new file mode 100644 index 00000000..f1395784 --- /dev/null +++ b/src/store/modules/iframe.js @@ -0,0 +1,38 @@ +export default { + state: { + iframeList: [] + }, + mutations: { + setIframeList(state, route){ + state.iframeList = [] + state.iframeList.push(route) + }, + pushIframeList(state, route){ + let target = state.iframeList.find((item) => item.path === route.path) + if(!target){ + state.iframeList.push(route) + } + }, + removeIframeList(state, route){ + state.iframeList.forEach((item, index) => { + if (item.path === route.path){ + state.iframeList.splice(index, 1) + } + }) + }, + refreshIframe(state, route){ + state.iframeList.forEach((item) => { + if (item.path == route.path){ + var url = route.meta.url; + item.meta.url = ''; + setTimeout(function() { + item.meta.url = url + }, 200); + } + }) + }, + clearIframeList(state){ + state.iframeList = [] + } + } +}