优化 page 模块
Former-commit-id: 0e2c9ad4b69ce423d38acb86bdd9dcb9789eec69 [formerly 64daf7a48edcfd52725015d9ce7a8b3f89db75bc] [formerly 0e2c9ad4b69ce423d38acb86bdd9dcb9789eec69 [formerly 64daf7a48edcfd52725015d9ce7a8b3f89db75bc] [formerly 0e2c9ad4b69ce423d38acb86bdd9dcb9789eec69 [formerly 64daf7a48edcfd52725015d9ce7a8b3f89db75bc] [formerly 64daf7a48edcfd52725015d9ce7a8b3f89db75bc [formerly 50cb57eb351c453c1b0b9f6184ec66bb4aba5d69 [formerly 844d50dcdb0759fe94874d2773147832cdd90ae5]]]]] Former-commit-id: 5f9f1091eb09e485505f69a78153139e1fc6f981 Former-commit-id: e1ad7e69a9a799baf047e449605c8a03ba52b494 Former-commit-id: ce753cbefc4ddb57f15d883a13c216eb36469e2a [formerly ba5f458deb00629170640602aa1b2dbca8de930d] Former-commit-id: 96132b91d55f020dbef7120577bb0c301006bd37 Former-commit-id: feb90df127bc272d98d14ea73742a17d4eb57baf Former-commit-id: eb81700bd799e1123a3c15a6c8e3a1b4328a75df Former-commit-id: 7784a23b33e0c41d9411289bf07dd2b5409f4243 Former-commit-id: 46c929b1e106368d23be310daf6a9524d93d62b8
This commit is contained in:
@@ -9,11 +9,7 @@ const db = low(adapter)
|
||||
db.defaults({
|
||||
// 新
|
||||
sys: {},
|
||||
db: {},
|
||||
// 旧
|
||||
opened: [],
|
||||
database: [],
|
||||
databasePublic: {}
|
||||
db: {}
|
||||
}).write()
|
||||
|
||||
export default db
|
||||
|
||||
@@ -55,7 +55,7 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
dbName: 'db',
|
||||
path: 'sandbox.demo-playground-db-util',
|
||||
path: 'demo-playground-db-util',
|
||||
key: 'demoKey',
|
||||
value: 'demo text',
|
||||
dbData: ''
|
||||
|
||||
@@ -93,6 +93,13 @@ export default {
|
||||
page.query = query || page.query
|
||||
state.opened.splice(index, 1, page)
|
||||
// 持久化
|
||||
this.commit('d2admin/page/opend2db')
|
||||
},
|
||||
/**
|
||||
* 将 opened 属性赋值并持久化 在这之前请先确保已经更新了 state.opened
|
||||
* @param {Object} state vuex state
|
||||
*/
|
||||
opend2db (state) {
|
||||
this.commit('d2admin/db/setByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'page.opened',
|
||||
@@ -109,7 +116,9 @@ export default {
|
||||
const value = await this.dispatch('d2admin/db/getByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'page.opened',
|
||||
defaultValue: []
|
||||
defaultValue: [
|
||||
openedDefult
|
||||
]
|
||||
})
|
||||
// 在处理函数中进行数据优化 过滤掉现在已经失效的页签或者已经改变了信息的页签
|
||||
// 以 name 字段为准
|
||||
@@ -131,6 +140,7 @@ export default {
|
||||
// 新的数据中一般不会携带 params 和 query, 所以旧的参数会留存
|
||||
return Object.assign({}, opened, find)
|
||||
}).filter((opened, index) => valid[index] === 1)
|
||||
console.log('state.opened', state.opened)
|
||||
},
|
||||
/**
|
||||
* @class opened
|
||||
@@ -146,11 +156,7 @@ export default {
|
||||
// 添加进当前显示的页面数组
|
||||
state.opened.push(newTag)
|
||||
// 持久化
|
||||
this.commit('d2admin/db/setByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'page.opened',
|
||||
value: state.opened
|
||||
})
|
||||
this.commit('d2admin/page/opend2db')
|
||||
},
|
||||
/**
|
||||
* @class opened
|
||||
@@ -183,11 +189,7 @@ export default {
|
||||
state.opened.splice(index, 1)
|
||||
}
|
||||
// 持久化
|
||||
this.commit('d2admin/db/setByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'page.opened',
|
||||
value: state.opened
|
||||
})
|
||||
this.commit('d2admin/page/opend2db')
|
||||
// 最后需要判断是否需要跳到首页
|
||||
if (isCurrent) {
|
||||
const { name = '', params = {}, query = {} } = newPage
|
||||
@@ -223,11 +225,7 @@ export default {
|
||||
})
|
||||
}
|
||||
// 持久化
|
||||
this.commit('d2admin/db/setByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'page.opened',
|
||||
value: state.opened
|
||||
})
|
||||
this.commit('d2admin/page/opend2db')
|
||||
},
|
||||
/**
|
||||
* @class opened
|
||||
@@ -251,11 +249,7 @@ export default {
|
||||
})
|
||||
}
|
||||
// 持久化
|
||||
this.commit('d2admin/db/setByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'page.opened',
|
||||
value: state.opened
|
||||
})
|
||||
this.commit('d2admin/page/opend2db')
|
||||
},
|
||||
/**
|
||||
* @class opened
|
||||
@@ -284,11 +278,7 @@ export default {
|
||||
})
|
||||
}
|
||||
// 持久化
|
||||
this.commit('d2admin/db/setByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'page.opened',
|
||||
value: state.opened
|
||||
})
|
||||
this.commit('d2admin/page/opend2db')
|
||||
},
|
||||
/**
|
||||
* @class opened
|
||||
@@ -299,11 +289,7 @@ export default {
|
||||
closeAll (state, vm) {
|
||||
state.opened.splice(1)
|
||||
// 持久化
|
||||
this.commit('d2admin/db/setByUser', {
|
||||
dbName: 'sys',
|
||||
path: 'page.opened',
|
||||
value: state.opened
|
||||
})
|
||||
this.commit('d2admin/page/opend2db')
|
||||
// 关闭所有的标签页后需要判断一次现在是不是在首页
|
||||
if (vm.$route.name !== 'index') {
|
||||
vm.$router.push({
|
||||
|
||||
Reference in New Issue
Block a user