You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.3 KiB
36 lines
1.3 KiB
7 months ago
|
import { viteThemePlugin } from './plugin/theme';
|
||
|
import { generateColors, getThemeColors } from './themeConfig';
|
||
|
import { mixLighten, mixDarken, tinycolor } from 'vite-plugin-theme';
|
||
|
export function theme({ isProd }) {
|
||
|
const colors = generateColors({
|
||
|
mixDarken,
|
||
|
mixLighten,
|
||
|
tinycolor,
|
||
|
});
|
||
|
return viteThemePlugin({
|
||
|
resolveSelector: (s) => {
|
||
|
s = s.trim();
|
||
|
switch (s) {
|
||
|
case '.ant-steps-item-process .ant-steps-item-icon > .ant-steps-icon':
|
||
|
return '.ant-steps-item-icon > .ant-steps-icon';
|
||
|
case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled)':
|
||
|
case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover':
|
||
|
case '.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):active':
|
||
|
return s;
|
||
|
case '.ant-steps-item-icon > .ant-steps-icon':
|
||
|
return s;
|
||
|
case '.ant-select-item-option-selected:not(.ant-select-item-option-disabled)':
|
||
|
return s;
|
||
|
default:
|
||
|
if (s.indexOf('.ant-btn') >= -1) {
|
||
|
// 按钮被重新定制过,需要过滤掉class防止覆盖
|
||
|
return s;
|
||
|
}
|
||
|
}
|
||
|
return s.startsWith('[data-theme') ? s : `[data-theme] ${s}`;
|
||
|
},
|
||
|
colorVariables: [...getThemeColors(), ...colors],
|
||
|
isProd,
|
||
|
});
|
||
|
}
|