project init

This commit is contained in:
zxy
2024-02-02 10:23:22 +08:00
commit dc7051417b
681 changed files with 142886 additions and 0 deletions

32
src/cache.js Normal file
View File

@@ -0,0 +1,32 @@
import Vue from 'vue'
import store from './store';
Vue.mixin({
beforeRouteLeave: function (to, from, next) {
if (this.$route.meta.keepAlive === true) {
const result = this.$route.meta.keepAlive === true && store.state.tags.tagList.some(ele => {
return ele.value === this.$route.fullPath;
});
if (this.$vnode && !result) {
if (this.$vnode.parent && this.$vnode.parent.componentInstance && this.$vnode.parent.componentInstance.cache) {
if (this.$vnode.componentOptions) {
let key = this.$vnode.key == null
? this.$vnode.componentOptions.Ctor.cid + (this.$vnode.componentOptions.tag ? `::${this.$vnode.componentOptions.tag}` : '')
: this.$vnode.key;
let cache = this.$vnode.parent.componentInstance.cache;
let keys = this.$vnode.parent.componentInstance.keys;
if (cache[key]) {
if (keys.length) {
let index = keys.indexOf(key);
if (index > -1) {
keys.splice(index, 1);
}
}
delete cache[key];
}
}
}
}
}
next();
},
});