Skip to content

Commit

Permalink
解决因当前theme改名或被删除导致持久化数据加载异常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
han-feng committed Nov 15, 2018
1 parent f9c6afe commit 5293fbc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/store/modules/d2admin/modules/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,25 @@ export default {
load ({ state, commit, dispatch }) {
return new Promise(async resolve => {
// store 赋值
state.activeName = await dispatch('d2admin/db/get', {
let activeName = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'theme.activeName',
defaultValue: state.list[0].name,
user: true
}, { root: true })
// 检查这个主题在主题列表里是否存在
if (state.list.find(e => e.name === activeName)) {
state.activeName = activeName
} else {
state.activeName = state.list[0].name
// 持久化
await dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'theme.activeName',
value: state.activeName,
user: true
}, { root: true })
}
// 将 vuex 中的主题应用到 dom
commit('dom')
// end
Expand Down

0 comments on commit 5293fbc

Please sign in to comment.