diff --git a/config/plugin.config.js b/config/plugin.config.js index 4582fe2fd48976a43c778ea429728f78833be1f7..b8056c92dff852a6b9209395d0c24789fc984cef 100644 --- a/config/plugin.config.js +++ b/config/plugin.config.js @@ -41,10 +41,21 @@ export default config => { outFile, }, ]); - config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [{ - fileName: 'css/theme-colors.css', - matchColors: generate('#1890ff'), // 主色系列 - }]); + config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [ + { + fileName: 'css/theme-colors.css', + matchColors: generate('#1890ff'), // 主色系列 + // 改变样式选择器,解决样式覆盖问题 + changeSelector(selector) { + switch (selector) { + case '.ant-calendar-today .ant-calendar-date': + return ':not(.ant-calendar-selected-day)' + selector; + default: + return selector; + } + }, + }, + ]); // config.plugin('ant-design-theme').use(AntDesignThemePlugin, [ // { // antDir: path.join(__dirname, '../node_modules/antd'), diff --git a/src/components/SettingDrawer/themeColorClient.js b/src/components/SettingDrawer/themeColorClient.js index 9918122c6f17bf00aa3d7b35240afa890e6fb3b3..9eeee6d74e86a3bebad5111b80bde9b96d8b9bec 100644 --- a/src/components/SettingDrawer/themeColorClient.js +++ b/src/components/SettingDrawer/themeColorClient.js @@ -1,22 +1,21 @@ /* eslint-disable import/no-extraneous-dependencies */ import generate from '@ant-design/colors/lib/generate'; -import client from 'webpack-theme-color-replacer/client' +import client from 'webpack-theme-color-replacer/client'; export default { primaryColor: '#1890ff', - getAntdSerials (color) { - return generate(color) + getAntdSerials(color) { + return generate(color); }, - changeColor (newColor) { - const lastColor = this.lastColor || this.primaryColor + changeColor(newColor) { + const lastColor = this.lastColor || this.primaryColor; const options = { cssUrl: '/css/theme-colors.css', // hash模式下用相对路径 oldColors: this.getAntdSerials(lastColor), // current colors array. The same as `matchColors` - newColors: this.getAntdSerials(newColor || this.primaryColor) // new colors array, one-to-one corresponde with `oldColors` - } + newColors: this.getAntdSerials(newColor || this.primaryColor), // new colors array, one-to-one corresponde with `oldColors` + }; const promise = client.changer.changeColor(options, Promise); - this.lastColor = lastColor - return promise - } -} - + this.lastColor = lastColor; + return promise; + }, +}; diff --git a/src/models/setting.js b/src/models/setting.js index 0ab74d90644885d80292e1a766a2ab0a53e57445..bb4df715b5951d0efb4409eeb3ecfe433aefb87d 100644 --- a/src/models/setting.js +++ b/src/models/setting.js @@ -1,12 +1,11 @@ import { message } from 'antd'; import defaultSettings from '../defaultSettings'; -import themeColorClient from '../components/SettingDrawer/themeColorClient' +import themeColorClient from '../components/SettingDrawer/themeColorClient'; const updateTheme = newPrimaryColor => { - const hideMessage = message.loading('正在切换主题!', 0) - themeColorClient.changeColor(newPrimaryColor) - .finally(() => hideMessage()) -} + const hideMessage = message.loading('正在切换主题!', 0); + themeColorClient.changeColor(newPrimaryColor).finally(() => hideMessage()); +}; /* let lessNodesAppended; const updateTheme = primaryColor => {