Pre Merge pull request !456 from smallwei/master
This commit is contained in:
commit
7432ef9c15
31
ruoyi-ui/src/cache.js
Normal file
31
ruoyi-ui/src/cache.js
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
})
|
@ -1,7 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="app-main">
|
<section class="app-main">
|
||||||
<transition name="fade-transform" mode="out-in">
|
<transition name="fade-transform"
|
||||||
<keep-alive :include="cachedViews">
|
mode="out-in">
|
||||||
|
<keep-alive>
|
||||||
<router-view :key="key" />
|
<router-view :key="key" />
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</transition>
|
</transition>
|
||||||
@ -12,10 +13,7 @@
|
|||||||
export default {
|
export default {
|
||||||
name: 'AppMain',
|
name: 'AppMain',
|
||||||
computed: {
|
computed: {
|
||||||
cachedViews() {
|
key () {
|
||||||
return this.$store.state.tagsView.cachedViews
|
|
||||||
},
|
|
||||||
key() {
|
|
||||||
return this.$route.path
|
return this.$route.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,7 +29,7 @@ export default {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fixed-header+.app-main {
|
.fixed-header + .app-main {
|
||||||
padding-top: 50px;
|
padding-top: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +39,7 @@ export default {
|
|||||||
min-height: calc(100vh - 84px);
|
min-height: calc(100vh - 84px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.fixed-header+.app-main {
|
.fixed-header + .app-main {
|
||||||
padding-top: 84px;
|
padding-top: 84px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import Cookies from 'js-cookie'
|
|||||||
|
|
||||||
import Element from 'element-ui'
|
import Element from 'element-ui'
|
||||||
import './assets/styles/element-variables.scss'
|
import './assets/styles/element-variables.scss'
|
||||||
|
import './cache.js'
|
||||||
import '@/assets/styles/index.scss' // global css
|
import '@/assets/styles/index.scss' // global css
|
||||||
import '@/assets/styles/ruoyi.scss' // ruoyi css
|
import '@/assets/styles/ruoyi.scss' // ruoyi css
|
||||||
import App from './App'
|
import App from './App'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user