feat: 优化合并的代码 完成刷新单页面功能

This commit is contained in:
FairyEver
2020-08-25 15:34:13 +08:00
parent 8560f87e8a
commit 5e3eadf0eb
3 changed files with 13 additions and 13 deletions

View File

@@ -63,7 +63,7 @@
<div class="d2-theme-container-main-body" flex-box="1">
<transition :name="transitionActive ? 'fade-transverse' : ''">
<keep-alive :include="keepAlive">
<router-view :key="$route.path + $route.meta[$route.path]" />
<router-view :key="routerViewKey" />
</keep-alive>
</transition>
</div>
@@ -126,6 +126,15 @@ export default {
...mapGetters('d2admin', {
themeActiveSetting: 'theme/activeSetting'
}),
/**
* @description 用来实现带参路由的缓存
*/
routerViewKey () {
// 默认情况下 key 类似 __transition-n-/foo
// 这里的字符串操作是为了最终 key 的格式和原来相同 类似 __transition-n-__stamp-time-/foo
const stamp = this.$route.meta[`__stamp-${this.$route.path}`] || ''
return `${stamp ? `__stamp-${stamp}-` : ''}${this.$route.path}`
},
/**
* @description 最外层容器的背景图片样式
*/