From 7e1a43143d723505bff3618d03a8542f964396fa Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Wed, 26 Jul 2023 09:17:48 +0800 Subject: [PATCH] =?UTF-8?q?Demo=EF=BC=9A=E5=88=87=E6=8D=A2=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E6=97=B6=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E8=A6=86=E7=9B=96=E8=AE=BE=E7=BD=AE=E8=BF=87=E7=9A=84?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Edit/components/Theme.vue | 34 ++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/web/src/pages/Edit/components/Theme.vue b/web/src/pages/Edit/components/Theme.vue index b294e411..b5f09302 100644 --- a/web/src/pages/Edit/components/Theme.vue +++ b/web/src/pages/Edit/components/Theme.vue @@ -42,7 +42,7 @@ export default { }, data() { return { - themeList: [...themeList].reverse(),// ...customThemeList + themeList: [...themeList].reverse(), // ...customThemeList themeMap, theme: '' } @@ -61,32 +61,48 @@ export default { } } }, - created () { + created() { this.theme = this.mindMap.getTheme() this.handleDark() }, methods: { ...mapMutations(['setIsDark']), - /** - * @Author: 王林 - * @Date: 2021-06-24 23:04:38 - * @Desc: 使用主题 - */ useTheme(theme) { this.theme = theme.value this.handleDark() + const customThemeConfig = this.mindMap.getCustomThemeConfig() + const hasCustomThemeConfig = Object.keys(customThemeConfig).length > 0 + if (hasCustomThemeConfig) { + this.$confirm('你当前自定义过基础样式,是否覆盖?', '提示', { + confirmButtonText: '覆盖', + cancelButtonText: '保留', + type: 'warning' + }) + .then(() => { + this.mindMap.setThemeConfig({}) + this.changeTheme(theme, {}) + }) + .catch(() => { + this.changeTheme(theme, customThemeConfig) + }) + } else { + this.changeTheme(theme, customThemeConfig) + } + }, + + changeTheme(theme, config) { this.mindMap.setTheme(theme.value) storeConfig({ theme: { template: theme.value, - config: this.mindMap.getCustomThemeConfig() + config } }) }, handleDark() { - let target = themeList.find((item) => { + let target = themeList.find(item => { return item.value === this.theme }) this.setIsDark(target.dark)