Commit 7f204e03 authored by 靳野's avatar 靳野

feat:去掉webpack-theme-color-replacer

parent 1dffb0a8
......@@ -2,7 +2,6 @@
// eslint-disable-next-line eslint-comments/abdeils - enable - pair;
/* eslint-disable import/no-extraneous-dependencies */
import ThemeColorReplacer from 'webpack-theme-color-replacer';
import generate from '@ant-design/colors/lib/generate';
import webpack from 'webpack';
const SentryPlugin = require('@qg/sentry-webpack-plugin');
......@@ -12,36 +11,6 @@ export default config => {
if (process.env.NODE_ENV === 'production') {
config.plugin('sentry-webpack-plugin').use(SentryPlugin, [SentryConfig]);
}
// preview.pro.ant.design only do not use in your production;
if (
process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ||
process.env.NODE_ENV !== 'production'
) {
config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [
{
fileName: 'css/theme-colors-[contenthash:8].css',
matchColors: getAntdSerials('#1890ff'),
// 主色系列
// 改变样式选择器,解决样式覆盖问题
changeSelector(selector) {
switch (selector) {
case '.ant-calendar-today .ant-calendar-date':
return ':not(.ant-calendar-selected-date)' + selector;
case '.ant-btn:focus,.ant-btn:hover':
return '.ant-btn:focus:not(.ant-btn-primary),.ant-btn:hover:not(.ant-btn-primary)';
case '.ant-btn.active,.ant-btn:active':
return '.ant-btn.active:not(.ant-btn-primary),.ant-btn:active:not(.ant-btn-primary)';
default:
return selector;
}
}, // isJsUgly: true,
},
]);
} // optimize chunks
if (process.env.SENTRY_ENV === 'prod') {
config.plugin('source-map-dev-tool-plugin').use(webpack.SourceMapDevToolPlugin, [
{
......
......@@ -27903,19 +27903,6 @@
"javascript-stringify": "^2.0.1"
}
},
"webpack-sources": {
"version": "3.2.3",
"resolved": "http://npmprivate.quantgroups.com/webpack-sources/-/webpack-sources-3.2.3.tgz",
"integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w=="
},
"webpack-theme-color-replacer": {
"version": "1.3.14",
"resolved": "http://npmprivate.quantgroups.com/webpack-theme-color-replacer/-/webpack-theme-color-replacer-1.3.14.tgz",
"integrity": "sha512-PKT/OD2+iXxGuGDxH/MVkt36EKYtYckowzPlZBdPOgGIVk8MbvLfdRFYOmWz6vhVJpyIGWtpfpoP9ecWZP8qYg==",
"requires": {
"webpack-sources": "*"
}
},
"websocket-driver": {
"version": "0.7.4",
"resolved": "http://npmprivate.quantgroups.com/websocket-driver/-/websocket-driver-0.7.4.tgz",
// eslint-disable-next-line eslint-comments/disable-enable-pair
/* eslint-disable import/no-extraneous-dependencies */
import client from 'webpack-theme-color-replacer/client';
import generate from '@ant-design/colors/lib/generate';
export default {
getAntdSerials(color) {
const lightCount = 9;
const divide = 10; // 淡化(即less的tint)
let lightens = new Array(lightCount).fill(0);
lightens = lightens.map((_, i) => client.varyColor.lighten(color, i / divide));
const colorPalettes = generate(color);
const rgb = client.varyColor.toNum3(color.replace('#', '')).join(',');
return lightens.concat(colorPalettes).concat(rgb);
},
changeColor(color) {
if (!color) {
return Promise.resolve();
}
const options = {
// new colors array, one-to-one corresponde with `matchColors`
newColors: this.getAntdSerials(color),
changeUrl(cssUrl) {
// while router is not `hash` mode, it needs absolute path
return `/${cssUrl}`;
},
};
return client.changer.changeColor(options, Promise);
},
};
import { message } from 'antd';
import defaultSettings from '../../config/defaultSettings';
import themeColorClient from '../components/SettingDrawer/themeColorClient';
const updateTheme = newPrimaryColor => {
if (newPrimaryColor) {
const timeOut = 0;
const hideMessage = message.loading('正在切换主题!', timeOut);
themeColorClient.changeColor(newPrimaryColor).finally(() => hideMessage());
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment