解决因当前theme改名或被删除导致持久化数据加载异常的问题

Former-commit-id: 625d8496dfae1a9c333570366984895175077acf [formerly 916001d3e57fa400864f4689ddc7373d07e4b545] [formerly 625d8496dfae1a9c333570366984895175077acf [formerly 916001d3e57fa400864f4689ddc7373d07e4b545] [formerly 625d8496dfae1a9c333570366984895175077acf [formerly 916001d3e57fa400864f4689ddc7373d07e4b545] [formerly 916001d3e57fa400864f4689ddc7373d07e4b545 [formerly 5a149d2414f743b3558dbb66eab0d9831bf676ee [formerly 626d4fc39f13c3b8cbe3088850eafc0f00c77b95]]]]]
Former-commit-id: 6f211854865cc0119d4105dd27136656e1428f6b
Former-commit-id: 1b643c97bc4a1c63e0f840693c659a70a357506c
Former-commit-id: c685693f0f72dc96bb3b1c19e637966a27211cf9 [formerly 44d490a3ed57ecaf6570a3b44373c1408244e374]
Former-commit-id: 3726d62671a67f821582e3327dce966b67be1584
Former-commit-id: 021b55854c39dab55da4f9d2d630c631b6dbef3c
Former-commit-id: 131996f42d6a8838c0161148670985c8e714c7f0
Former-commit-id: 2ee66f826cc63a182b1307d882a15d03bd135afd
Former-commit-id: 230f5dbe791bc3485049ab8980bcfb33e4768f0b
This commit is contained in:
han_feng
2018-11-15 11:44:26 +08:00
parent 229be3c546
commit e471cccad2

View File

@@ -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