Former-commit-id: 09dff142f713ef2363b20db831fd2aba22fef631
This commit is contained in:
FairyEver
2019-07-16 10:07:54 +08:00
parent c0785ccd1f
commit e703cf400e
2 changed files with 14 additions and 2 deletions
+9 -1
View File
@@ -53,9 +53,17 @@ router.beforeEach((to, from, next) => {
} }
}) })
router.afterEach(to => { router.afterEach(async to => {
// 进度条 // 进度条
NProgress.done() 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) store.dispatch('d2admin/page/open', to)
// 更改标题 // 更改标题
+5 -1
View File
@@ -12,6 +12,8 @@ export default {
pool: [], pool: [],
// 当前显示的多页面列表 // 当前显示的多页面列表
opened: setting.page.opened, opened: setting.page.opened,
// 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
openedLoaded: false,
// 当前页面 // 当前页面
current: '', current: '',
// 需要缓存的页面 name // 需要缓存的页面 name
@@ -20,7 +22,7 @@ export default {
actions: { actions: {
/** /**
* @class opened * @class opened
* @description 从持久化数据载入分页列表 * @description 从持久化数据载入标签页列表
* @param {Object} state vuex state * @param {Object} state vuex state
*/ */
openedLoad ({ state, commit, dispatch }) { openedLoad ({ state, commit, dispatch }) {
@@ -52,6 +54,8 @@ export default {
// 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存 // 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存
return Object.assign({}, opened, find) return Object.assign({}, opened, find)
}).filter((opened, index) => valid[index] === 1) }).filter((opened, index) => valid[index] === 1)
// 标记已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
state.openedLoaded = true
// 根据 opened 数据生成缓存设置 // 根据 opened 数据生成缓存设置
commit('keepAliveRefresh') commit('keepAliveRefresh')
// end // end