From 5293fbc4626326b3a48b0544baafc1dddf386fcc Mon Sep 17 00:00:00 2001 From: han_feng Date: Thu, 15 Nov 2018 11:44:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9B=A0=E5=BD=93=E5=89=8Dth?= =?UTF-8?q?eme=E6=94=B9=E5=90=8D=E6=88=96=E8=A2=AB=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=8C=81=E4=B9=85=E5=8C=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/d2admin/modules/theme.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/store/modules/d2admin/modules/theme.js b/src/store/modules/d2admin/modules/theme.js index c24603104..ae6535142 100644 --- a/src/store/modules/d2admin/modules/theme.js +++ b/src/store/modules/d2admin/modules/theme.js @@ -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