|  | @@ -1,7 +1,7 @@
 | 
											
												
													
														|  |  <template>
 |  |  <template>
 | 
											
												
													
														|  |    <section class="app-main">
 |  |    <section class="app-main">
 | 
											
												
													
														|  |      <transition name="fade-transform" mode="out-in">
 |  |      <transition name="fade-transform" mode="out-in">
 | 
											
												
													
														|  | -      <keep-alive :include="cachedViews">
 |  | 
 | 
											
												
													
														|  | 
 |  | +      <keep-alive :max="maxCacheCount">
 | 
											
												
													
														|  |          <router-view :key="key"/>
 |  |          <router-view :key="key"/>
 | 
											
												
													
														|  |        </keep-alive>
 |  |        </keep-alive>
 | 
											
												
													
														|  |      </transition>
 |  |      </transition>
 | 
											
										
											
												
													
														|  | @@ -11,12 +11,23 @@
 | 
											
												
													
														|  |  <script>
 |  |  <script>
 | 
											
												
													
														|  |  export default {
 |  |  export default {
 | 
											
												
													
														|  |    name: 'AppMain',
 |  |    name: 'AppMain',
 | 
											
												
													
														|  | 
 |  | +  data() {
 | 
											
												
													
														|  | 
 |  | +    return {
 | 
											
												
													
														|  | 
 |  | +      maxCacheCount: 5 // 最多缓存尺寸 // 5.11 hht 加个尺寸控制,防止key值缓存过多
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +  },
 | 
											
												
													
														|  |    computed: {
 |  |    computed: {
 | 
											
												
													
														|  |      cachedViews() {
 |  |      cachedViews() {
 | 
											
												
													
														|  |        return this.$store.state.tagsView.cachedViews
 |  |        return this.$store.state.tagsView.cachedViews
 | 
											
												
													
														|  |      },
 |  |      },
 | 
											
												
													
														|  |      key() {
 |  |      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
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  }
 |  |  }
 |