From d5936708358fcfffc30817e25120bf9e4049c8b3 Mon Sep 17 00:00:00 2001 From: chenghongxing <1126263215@qq.com> Date: Sat, 26 Sep 2020 11:05:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20setting=20of=20local=20saving=20do=20not?= =?UTF-8?q?=20work=20in=20some=20case;=20:bug:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=EF=BC=9A=E6=9C=89=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E4=BF=9D=E5=AD=98=E9=85=8D=E7=BD=AE=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/setting/Setting.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/setting/Setting.vue b/src/components/setting/Setting.vue index cd84041..4d64b14 100644 --- a/src/components/setting/Setting.vue +++ b/src/components/setting/Setting.vue @@ -123,7 +123,9 @@ import Clipboard from 'clipboard' import { mapState, mapMutations } from 'vuex' import {formatConfig} from '@/utils/formatter' import {setting} from '@/config/default' +import sysConfig from '@/config/config' import fastEqual from 'fast-deep-equal' +import deepMerge from 'deepmerge' const ColorCheckboxGroup = ColorCheckbox.Group const ImgCheckboxGroup = ImgCheckbox.Group @@ -153,7 +155,7 @@ export default { return this.$el.parentNode }, copyCode () { - let config = this.extractConfig() + let config = this.extractConfig(false) this.copyConfig = `// 自定义配置,参考 ./default/setting.config.js,需要自定义的属性在这里配置即可 module.exports = ${formatConfig(config)} ` @@ -171,7 +173,7 @@ export default { }, saveSetting() { const closeMessage = this.$message.loading('正在保存到本地,请稍后...', 0) - const config = this.extractConfig() + const config = this.extractConfig(true) localStorage.setItem(process.env.VUE_APP_SETTING_KEY, JSON.stringify(config)) setTimeout(closeMessage, 800) }, @@ -185,11 +187,12 @@ export default { }) }, //提取配置 - extractConfig() { + extractConfig(local = false) { let config = {} let mySetting = this.$store.state.setting + let dftSetting = local ? deepMerge(setting, sysConfig) : setting Object.keys(mySetting).forEach(key => { - const dftValue = setting[key], myValue = mySetting[key] + const dftValue = dftSetting[key], myValue = mySetting[key] if (dftValue != undefined && !fastEqual(dftValue, myValue)) { config[key] = myValue }