From c83a1d899a94c7dc4a3e8171c02e1c4f7ff5e01d Mon Sep 17 00:00:00 2001 From: hz Date: Sun, 26 May 2019 14:59:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E9=97=AE=E9=A2=98=EF=BC=9B=20npm=20run=20prettier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/plugin.config.js | 19 +++++++++++---- .../SettingDrawer/themeColorClient.js | 23 +++++++++---------- src/models/setting.js | 9 ++++---- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/config/plugin.config.js b/config/plugin.config.js index 4582fe2f..b8056c92 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 9918122c..9eeee6d7 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 0ab74d90..bb4df715 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 => { -- GitLab