Merge 169105358c into 33a93a12b4
				
					
				
			This commit is contained in:
		| @@ -13,9 +13,13 @@ const mutations = { | |||||||
|     ) |     ) | ||||||
|   }, |   }, | ||||||
|   ADD_CACHED_VIEW: (state, view) => { |   ADD_CACHED_VIEW: (state, view) => { | ||||||
|     if (state.cachedViews.includes(view.name)) return |  | ||||||
|     if (!view.meta.noCache) { |     if (!view.meta.noCache) { | ||||||
|       state.cachedViews.push(view.name) |       for (const matchedView of view.matched) { | ||||||
|  |         const { name } = matchedView.components.default | ||||||
|  |         if (name && state.cachedViews.indexOf(name) === -1) { | ||||||
|  |           state.cachedViews.push(name) | ||||||
|  |         } | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
| @@ -28,8 +32,9 @@ const mutations = { | |||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   DEL_CACHED_VIEW: (state, view) => { |   DEL_CACHED_VIEW: (state, view) => { | ||||||
|     const index = state.cachedViews.indexOf(view.name) |     const deletedViewName = view.matched[view.matched.length - 1].components.default.name | ||||||
|     index > -1 && state.cachedViews.splice(index, 1) |     const index = state.cachedViews.indexOf(deletedViewName) | ||||||
|  |     state.cachedViews.splice(index, 1) | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|   DEL_OTHERS_VISITED_VIEWS: (state, view) => { |   DEL_OTHERS_VISITED_VIEWS: (state, view) => { | ||||||
| @@ -38,9 +43,10 @@ const mutations = { | |||||||
|     }) |     }) | ||||||
|   }, |   }, | ||||||
|   DEL_OTHERS_CACHED_VIEWS: (state, view) => { |   DEL_OTHERS_CACHED_VIEWS: (state, view) => { | ||||||
|     const index = state.cachedViews.indexOf(view.name) |     const currentViewName = view.matched[view.matched.length - 1].components.default.name | ||||||
|  |     const index = state.cachedViews.indexOf(currentViewName) | ||||||
|     if (index > -1) { |     if (index > -1) { | ||||||
|       state.cachedViews = state.cachedViews.slice(index, index + 1) |       state.cachedViews = view.matched.map(i => i.components.default.name) | ||||||
|     } else { |     } else { | ||||||
|       // if index = -1, there is no cached tags |       // if index = -1, there is no cached tags | ||||||
|       state.cachedViews = [] |       state.cachedViews = [] | ||||||
|   | |||||||
| @@ -5,3 +5,17 @@ | |||||||
|     </el-alert> |     </el-alert> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | export default { | ||||||
|  |   name: 'Menu1', | ||||||
|  |   computed: { | ||||||
|  |     cachedViews() { | ||||||
|  |       return this.$store.state.tagsView.cachedViews | ||||||
|  |     }, | ||||||
|  |     key() { | ||||||
|  |       return this.$route.path | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
|   | |||||||
| @@ -1,7 +1,23 @@ | |||||||
| <template> | <template> | ||||||
|   <div style="padding:30px;"> |   <div style="padding:30px;"> | ||||||
|     <el-alert :closable="false" title="menu 1-2" type="success"> |     <el-alert :closable="false" title="menu 1-2" type="success"> | ||||||
|       <router-view /> |       <keep-alive :include="cachedViews"> | ||||||
|  |         <router-view :key="key" /> | ||||||
|  |       </keep-alive> | ||||||
|     </el-alert> |     </el-alert> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | export default { | ||||||
|  |   name: 'Menu12', | ||||||
|  |   computed: { | ||||||
|  |     cachedViews() { | ||||||
|  |       return this.$store.state.tagsView.cachedViews | ||||||
|  |     }, | ||||||
|  |     key() { | ||||||
|  |       return this.$route.path | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
|   | |||||||
| @@ -1,5 +1,18 @@ | |||||||
| <template functional> | <template> | ||||||
|   <div style="padding:30px;"> |   <div style="padding:30px;"> | ||||||
|     <el-alert :closable="false" title="menu 1-2-1" type="warning" /> |     <el-alert :closable="false" title="menu 1-2-1" type="warning"> | ||||||
|  |       <el-input key="Menu121" v-model="input" /> | ||||||
|  |     </el-alert> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | export default { | ||||||
|  |   name: 'Menu121', | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       input: '' | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
|   | |||||||
| @@ -1,5 +1,18 @@ | |||||||
| <template functional> | <template> | ||||||
|   <div style="padding:30px;"> |   <div style="padding:30px;"> | ||||||
|     <el-alert :closable="false" title="menu 1-2-2" type="warning" /> |     <el-alert :closable="false" title="menu 1-2-2" type="warning"> | ||||||
|  |       <el-input key="Menu122" v-model="input" /> | ||||||
|  |     </el-alert> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | export default { | ||||||
|  |   name: 'Menu122', | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       input: '' | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user