|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<section class="app-main">
|
|
|
<transition name="fade-transform" mode="out-in">
|
|
|
- <keep-alive :include="cachedViews">
|
|
|
+ <keep-alive :max="maxCacheCount">
|
|
|
<router-view :key="key"/>
|
|
|
</keep-alive>
|
|
|
</transition>
|
|
@@ -11,12 +11,23 @@
|
|
|
<script>
|
|
|
export default {
|
|
|
name: 'AppMain',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ maxCacheCount: 5 // 最多缓存尺寸 // 5.11 hht 加个尺寸控制,防止key值缓存过多
|
|
|
+ }
|
|
|
+ },
|
|
|
computed: {
|
|
|
cachedViews() {
|
|
|
return this.$store.state.tagsView.cachedViews
|
|
|
},
|
|
|
key() {
|
|
|
- return this.$route.path
|
|
|
+ // TODO: 5.11 hht keep-alive的include/exclude结合router-view好像不能正常工作, 目前没有弄清原因
|
|
|
+ // NOTE: 先通过key的途径解决缓存刷新的问题
|
|
|
+ const meta = this.$route.meta
|
|
|
+ const useCache = meta && meta.hasOwnProperty('noCache') && meta.noCache === false
|
|
|
+ const fullPath = this.$route.fullPath
|
|
|
+ const cacheControlArgs = useCache ? '' : ('_' + new Date().getTime())
|
|
|
+ return fullPath + cacheControlArgs
|
|
|
}
|
|
|
}
|
|
|
}
|