Commit 63900da8c27e7e18525638def75663db90823756
1 parent
170c0dbc
v3.7.0 修复保存配置主题颜色失效问题
Showing
2 changed files
with
15 additions
and
6 deletions
yudao-ui-admin/src/components/ThemePicker/index.vue
| @@ -31,13 +31,24 @@ export default { | @@ -31,13 +31,24 @@ export default { | ||
| 31 | immediate: true | 31 | immediate: true |
| 32 | }, | 32 | }, |
| 33 | async theme(val) { | 33 | async theme(val) { |
| 34 | + await this.setTheme(val) | ||
| 35 | + } | ||
| 36 | + }, | ||
| 37 | + created() { | ||
| 38 | + if(this.defaultTheme !== ORIGINAL_THEME) { | ||
| 39 | + this.setTheme(this.defaultTheme) | ||
| 40 | + } | ||
| 41 | + }, | ||
| 42 | + | ||
| 43 | + methods: { | ||
| 44 | + async setTheme(val) { | ||
| 34 | const oldVal = this.chalk ? this.theme : ORIGINAL_THEME | 45 | const oldVal = this.chalk ? this.theme : ORIGINAL_THEME |
| 35 | if (typeof val !== 'string') return | 46 | if (typeof val !== 'string') return |
| 36 | const themeCluster = this.getThemeCluster(val.replace('#', '')) | 47 | const themeCluster = this.getThemeCluster(val.replace('#', '')) |
| 37 | const originalCluster = this.getThemeCluster(oldVal.replace('#', '')) | 48 | const originalCluster = this.getThemeCluster(oldVal.replace('#', '')) |
| 38 | 49 | ||
| 39 | const $message = this.$message({ | 50 | const $message = this.$message({ |
| 40 | - message: ' Compiling the theme', | 51 | + message: ' 正在切换主题,请稍后...', |
| 41 | customClass: 'theme-message', | 52 | customClass: 'theme-message', |
| 42 | type: 'success', | 53 | type: 'success', |
| 43 | duration: 0, | 54 | duration: 0, |
| @@ -82,10 +93,9 @@ export default { | @@ -82,10 +93,9 @@ export default { | ||
| 82 | this.$emit('change', val) | 93 | this.$emit('change', val) |
| 83 | 94 | ||
| 84 | $message.close() | 95 | $message.close() |
| 85 | - } | ||
| 86 | - }, | ||
| 87 | 96 | ||
| 88 | - methods: { | 97 | + }, |
| 98 | + | ||
| 89 | updateStyle(style, oldCluster, newCluster) { | 99 | updateStyle(style, oldCluster, newCluster) { |
| 90 | let newStyle = style | 100 | let newStyle = style |
| 91 | oldCluster.forEach((color, index) => { | 101 | oldCluster.forEach((color, index) => { |
yudao-ui-admin/src/store/modules/settings.js
| 1 | -import variables from '@/assets/styles/element-variables.scss' | ||
| 2 | import defaultSettings from '@/settings' | 1 | import defaultSettings from '@/settings' |
| 3 | 2 | ||
| 4 | const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings | 3 | const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings |
| @@ -6,7 +5,7 @@ const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dyn | @@ -6,7 +5,7 @@ const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dyn | ||
| 6 | const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' | 5 | const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' |
| 7 | const state = { | 6 | const state = { |
| 8 | title: '', | 7 | title: '', |
| 9 | - theme: storageSetting.theme || variables.theme, | 8 | + theme: storageSetting.theme || '#409EFF', |
| 10 | sideTheme: storageSetting.sideTheme || sideTheme, | 9 | sideTheme: storageSetting.sideTheme || sideTheme, |
| 11 | showSettings: showSettings, | 10 | showSettings: showSettings, |
| 12 | topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, | 11 | topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, |