优化等待加载数据的写法

Former-commit-id: 7809445278ada4428e805392c1c74e6e23d535d5 [formerly 7809445278ada4428e805392c1c74e6e23d535d5 [formerly 7809445278ada4428e805392c1c74e6e23d535d5 [formerly 7809445278ada4428e805392c1c74e6e23d535d5 [formerly ace2c2a58253ce3f9a56c78a7808c580021a2936 [formerly 2eb3b298bc56bfa2e28947e2384da9afd8b62d7e]]]]]
Former-commit-id: 8f13d8c2018f66b3087fbeb21f95b28acfbd290b
Former-commit-id: 3f813f3490893b93e9f3b37469206612d3fabb8f
Former-commit-id: 570afa5e4472ad8aa025a8f0db56a0643116e14e [formerly 55d5504bef46d75474e6ac27b78f03d09ce8be7c]
Former-commit-id: 77c11b4f77ac587c3c9025c9b88e8ea913a38ea8
Former-commit-id: c77e00d5399f77afd4f453d7922c7b9ba4dcf6a2
Former-commit-id: 8a947ed537946139c236d6415d4a81047e0deb8c
Former-commit-id: 94be69316dd385b4b3d74a26c517f80a2f9da0ec
Former-commit-id: 1926124e7eee320fbfe7826b70ed2fe21fdfa427
This commit is contained in:
FairyEver
2019-07-16 20:48:01 +08:00
parent bf2abb9a7a
commit 8b4c84c44f
3 changed files with 5 additions and 11 deletions

View File

@@ -24,15 +24,9 @@ const router = new VueRouter({
* 权限验证
*/
router.beforeEach(async (to, from, next) => {
// 等待数据加载 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)
})
// 等待加载组件尺寸 https://github.com/d2-projects/d2-admin/issues/198
// 确认已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
await store.dispatch('d2admin/page/isLoaded')
// 确认已经加载组件尺寸设置 https://github.com/d2-projects/d2-admin/issues/198
await store.dispatch('d2admin/size/isLoaded')
// 进度条
NProgress.start()

View File

@@ -1 +1 @@
9497ec44eb1bff086d98a4917a8aba46abed1fe0
f6db6b641667fe94ef45b30706bc285c62e33d1b

View File

@@ -20,7 +20,7 @@ export default {
}
},
/**
* @description 确认组件尺寸已经加载 https://github.com/d2-projects/d2-admin/issues/198
* @description 确认已经加载组件尺寸设置 https://github.com/d2-projects/d2-admin/issues/198
*/
isLoaded ({ state }) {
if (state.value) return Promise.resolve()