From e703cf400ea48e6c58982dfced6359d88ecf2fcc Mon Sep 17 00:00:00 2001 From: FairyEver <1711467488@qq.com> Date: Tue, 16 Jul 2019 10:07:54 +0800 Subject: [PATCH 1/2] fixed #201 Former-commit-id: 09dff142f713ef2363b20db831fd2aba22fef631 --- src/router/index.js | 10 +++++++++- src/store/modules/d2admin/modules/page.js | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 2e11da2..be69996 100755 --- a/src/router/index.js +++ b/src/router/index.js @@ -53,9 +53,17 @@ router.beforeEach((to, from, next) => { } }) -router.afterEach(to => { +router.afterEach(async to => { // 进度条 NProgress.done() + // 等待数据加载 https://github.com/d2-projects/d2-admin/issues/201 + await new Promise (resolve => { + const timer = setInterval(() => { + if (store.state.d2admin.page.openedLoaded) { + resolve(clearInterval(timer)) + } + }, 10) + }) // 多页控制 打开新的页面 store.dispatch('d2admin/page/open', to) // 更改标题 diff --git a/src/store/modules/d2admin/modules/page.js b/src/store/modules/d2admin/modules/page.js index 4b3ff75..9497ec4 100644 --- a/src/store/modules/d2admin/modules/page.js +++ b/src/store/modules/d2admin/modules/page.js @@ -12,6 +12,8 @@ export default { pool: [], // 当前显示的多页面列表 opened: setting.page.opened, + // 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201 + openedLoaded: false, // 当前页面 current: '', // 需要缓存的页面 name @@ -20,7 +22,7 @@ export default { actions: { /** * @class opened - * @description 从持久化数据载入分页列表 + * @description 从持久化数据载入标签页列表 * @param {Object} state vuex state */ openedLoad ({ state, commit, dispatch }) { @@ -52,6 +54,8 @@ export default { // 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存 return Object.assign({}, opened, find) }).filter((opened, index) => valid[index] === 1) + // 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201 + state.openedLoaded = true // 根据 opened 数据生成缓存设置 commit('keepAliveRefresh') // end From 3ab623ab719f8c494503a6720b429ce001b9b386 Mon Sep 17 00:00:00 2001 From: FairyEver <1711467488@qq.com> Date: Tue, 16 Jul 2019 10:11:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=81=B0=E9=A5=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: ac1aea1293bdae633e82bdd759aa14712c00693f --- src/menu/header.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/menu/header.js b/src/menu/header.js index e217566..901bd79 100644 --- a/src/menu/header.js +++ b/src/menu/header.js @@ -9,5 +9,13 @@ export default [ { path: '/demo/page2', title: '页面 2' }, { path: '/demo/page3', title: '页面 3' } ] - } + }, + // 恰饭 + ...process.env.VUE_APP_BUILD_MODE === 'TRAVIS' ? [ + { + path: 'https://gio.ren/w/nP2OALom', + title: 'Web进阶教程', + icon: 'book' + } + ] : [] ]