From 93c5209a563088e56b0aa6a4409ce0ad0484e0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=80=9D=E7=BB=B4=E7=A9=BA=E9=97=B4?= Date: Thu, 23 Apr 2020 14:28:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=88=E6=8C=81=E4=B9=85=E5=8C=96,=E5=86=8D?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/d2admin/modules/page.js | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/store/modules/d2admin/modules/page.js b/src/store/modules/d2admin/modules/page.js index 598fd88b..9cb5d6bc 100644 --- a/src/store/modules/d2admin/modules/page.js +++ b/src/store/modules/d2admin/modules/page.js @@ -207,15 +207,11 @@ export default { } // 持久化 await dispatch('opened2db') - // 最后需要判断是否需要跳到首页 + // 决定最后停留的页面 if (isCurrent) { const { name = 'index', params = {}, query = {} } = newPage - let routerObj = { - name, - params, - query - } - router.push(routerObj) + let routerObj = { name, params, query } + await router.push(routerObj) } }, /** @@ -241,10 +237,11 @@ export default { state.opened.splice(i, 1) } } - state.current = pageAim - if (router.app.$route.fullPath !== pageAim) router.push(pageAim) // 持久化 await dispatch('opened2db') + // 设置当前的页面 + state.current = pageAim + if (router.app.$route.fullPath !== pageAim) await router.push(pageAim) }, /** * @class opened @@ -267,11 +264,11 @@ export default { commit('keepAliveRemove', state.opened[i].name) state.opened.splice(i, 1) } - // 设置当前的页面 - state.current = pageAim - if (router.app.$route.fullPath !== pageAim) router.push(pageAim) // 持久化 await dispatch('opened2db') + // 设置当前的页面 + state.current = pageAim + if (router.app.$route.fullPath !== pageAim) await router.push(pageAim) }, /** * @class opened @@ -294,11 +291,11 @@ export default { commit('keepAliveRemove', state.opened[i].name) state.opened.splice(i, 1) } - // 设置新的页面 - state.current = pageAim - if (router.app.$route.fullPath !== pageAim) router.push(pageAim) // 持久化 await dispatch('opened2db') + // 设置新的页面 + state.current = pageAim + if (router.app.$route.fullPath !== pageAim) await router.push(pageAim) }, /** * @class opened @@ -319,7 +316,7 @@ export default { await dispatch('opened2db') // 关闭所有的标签页后需要判断一次现在是不是在首页 if (router.app.$route.name !== 'index') { - router.push({ name: 'index' }) + await router.push({ name: 'index' }) } } },