diff --git a/ruoyi-ui/src/cache.js b/ruoyi-ui/src/cache.js new file mode 100644 index 000000000..a5f4bc941 --- /dev/null +++ b/ruoyi-ui/src/cache.js @@ -0,0 +1,31 @@ +import Vue from 'vue' +import store from './store' +Vue.mixin({ + beforeRouteLeave: function (to, from, next) { + let list = store.state.tagsView.visitedViews + if (this.$vnode) { + if (this.$vnode.parent && this.$vnode.parent.componentInstance && this.$vnode.parent.componentInstance.cache) { + if (this.$vnode.componentOptions) { + var cache = this.$vnode.parent.componentInstance.cache; + var keys = this.$vnode.parent.componentInstance.keys; + keys.forEach(key => { + let t = {} + let i = list.findIndex(tag => { + if (key.indexOf(tag.path) !== -1) { + t = tag; + return true; + } + return false; + }) + let meta = t.meta || {} + if (i == -1 || meta.noCache == true) { + keys.splice(i, 1); + delete cache[key]; + } + }) + } + } + } + next(); + } +}) \ No newline at end of file diff --git a/ruoyi-ui/src/layout/components/AppMain.vue b/ruoyi-ui/src/layout/components/AppMain.vue index 7cc667488..899a09333 100644 --- a/ruoyi-ui/src/layout/components/AppMain.vue +++ b/ruoyi-ui/src/layout/components/AppMain.vue @@ -1,7 +1,8 @@