简化代码

Former-commit-id: 0cd1782dde2a30d9086ac47d5ded9dc4df29de48 [formerly 9e1858cec7428c6ce7e267035098036bb151fd28] [formerly 0cd1782dde2a30d9086ac47d5ded9dc4df29de48 [formerly 9e1858cec7428c6ce7e267035098036bb151fd28] [formerly 0cd1782dde2a30d9086ac47d5ded9dc4df29de48 [formerly 9e1858cec7428c6ce7e267035098036bb151fd28] [formerly 9e1858cec7428c6ce7e267035098036bb151fd28 [formerly b71beb1e80d84426b85dee99161787d661e66fab [formerly a94aedf53923d940571248f02f3162a3bcd3fcf6]]]]]
Former-commit-id: c7fa1ef6d2aa3a23acc0475f4910bcee4561a34c
Former-commit-id: b1e6dfba9a437595921d28df2c9dae5de302237e
Former-commit-id: 2b53acd6182d0e0be646434eeb36f4b9fa37db06 [formerly de09db614187dd24b70e35a61dbcffcb2125361e]
Former-commit-id: ed3a4cea8108b87753f79d8f21c175b6a47f2f92
Former-commit-id: 373d1a05c166497cd29ee37d6b69fdb28a8f7e83
Former-commit-id: e3dbc10921d1cb71b277c3b224164b1cb6315d00
Former-commit-id: 7c24c8a925fb025dd36244ed580bb15c3219caf9
Former-commit-id: 90ea668a9eeea36d828202d419e1f88024893c4b
This commit is contained in:
liyang
2018-08-11 14:37:21 +08:00
parent ce26ad2705
commit 0ac0d31a7a
3 changed files with 13 additions and 9 deletions

View File

@@ -44,7 +44,7 @@
</div>
<div class="d2-theme-container-main-body" flex-box="1">
<transition name="fade-transverse">
<keep-alive :include="keepAliveInclude">
<keep-alive :include="keepAlive">
<router-view/>
</keep-alive>
</transition>
@@ -83,7 +83,7 @@ export default {
asideCollapse: state => state.menu.asideCollapse
}),
...mapGetters('d2admin', {
keepAliveInclude: 'page/keepAliveInclude',
keepAlive: 'page/keepAlive',
themeActiveSetting: 'theme/activeSetting'
}),
/**

View File

@@ -111,8 +111,8 @@
<div style="height: 300px; overflow: auto;">
<tree-view
class="tree-view-small"
:data="keepAliveInclude"
:options="{ rootObjectKey: 'keepAliveInclude', maxDepth: 1 }"/>
:data="keepAlive"
:options="{ rootObjectKey: 'keepAlive', maxDepth: 1 }"/>
</div>
</el-card>
</el-col>
@@ -156,7 +156,7 @@ export default {
pageopened: state => state.page.opened
}),
...mapGetters('d2admin', {
keepAliveInclude: 'page/keepAliveInclude',
keepAlive: 'page/keepAlive',
themeActiveSetting: 'theme/activeSetting'
})
}

View File

@@ -23,7 +23,7 @@ export default {
* @description 从当前所有打开的多标签页里返回需要缓存的页面 name
* @param {*} state vuex state
*/
keepAliveInclude (state) {
keepAlive (state) {
return state.opened.filter(item => {
if (item.meta) {
if (item.meta.notCache) {
@@ -53,7 +53,7 @@ export default {
})
if (pageOpend) {
// 页面以前打开过 但是新的页面可能 name 一样,参数不一样
this.commit('d2admin/page/openedUpdateItem', {
this.commit('d2admin/page/openedUpdate', {
index: pageOpendIndex,
params,
query
@@ -62,7 +62,11 @@ export default {
// 页面以前没有打开过
let page = state.pool.find(t => t.name === name)
if (page) {
this.commit('d2admin/page/add', { tag: page, params, query })
this.commit('d2admin/page/add', {
tag: page,
params,
query
})
}
}
this.commit('d2admin/page/currentSet', name)
@@ -82,7 +86,7 @@ export default {
* @param {Object} state vuex state
* @param {Object} param { index, params, query } 路由信息
*/
openedUpdateItem (state, { index, params, query }) {
openedUpdate (state, { index, params, query }) {
// 更新页面列表某一项
let page = state.opened[index]
page.params = params || page.params