Merge branch 'develop'

Former-commit-id: c8b54cc305296e9d287f1e2941cff9c97861a8fa
This commit is contained in:
FairyEver
2019-07-16 10:11:08 +08:00
3 changed files with 23 additions and 3 deletions
+8
View File
@@ -9,5 +9,13 @@ export default [
{ path: '/page2', title: '页面 2' },
{ path: '/page3', title: '页面 3' }
]
},
// 恰饭
...process.env.VUE_APP_BUILD_MODE === 'TRAVIS' ? [
{
path: 'https://gio.ren/w/nP2OALom',
title: 'Web进阶教程',
icon: 'book'
}
] : []
]
+9 -1
View File
@@ -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)
// 更改标题
+5 -1
View File
@@ -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