From e471cccad2a9e58255d21b9df40c9047af3eac18 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 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 --- 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 c2460310..ae653514 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