Skip to content

Commit

Permalink
fixed #201
Browse files Browse the repository at this point in the history
  • Loading branch information
FairyEver committed Jul 15, 2019
1 parent c8bd4ac commit 90ab115
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@ 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)
// 更改标题
Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/d2admin/modules/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default {
pool: [],
// 当前显示的多页面列表
opened: setting.page.opened,
// 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
openedLoaded: false,
// 当前页面
current: '',
// 需要缓存的页面 name
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 90ab115

Please sign in to comment.