From 6c2dfc29f2dd445fa6ff5ffbfe069dcdabc9069a Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Fri, 23 Sep 2022 18:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91=E5=90=8E?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E8=89=B2=E5=88=87=E6=8D=A2=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=E9=BB=91=E5=B1=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/vite/plugin/theme.ts | 65 ++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/build/vite/plugin/theme.ts b/build/vite/plugin/theme.ts index db6764c..8b24dfe 100644 --- a/build/vite/plugin/theme.ts +++ b/build/vite/plugin/theme.ts @@ -14,31 +14,47 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] { mixLighten, tinycolor, }); + + // update-begin-修复编译后主题色切换不生效黑屏的问题----------------------- + // https://github.com/vbenjs/vue-vben-admin/issues/1445 + // 抽取出viteThemePlugin插件,下方会根据不同环境设置enforce + const vite_theme_plugin = 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], + }); + vite_theme_plugin.forEach(function (item) { + //对vite:theme插件特殊配置 + if ('vite:theme' === item.name) { + // 打包时去除enforce: "post",vite 2.6.x适配,否则生成app-theme-style为空,因为async transform(code, id) {的code没有正确获取 + if (isBuild) { + delete item.enforce; + } + } + }); + // update-end-修复编译后主题色切换不生效黑屏的问题----------------------- + const plugin = [ - 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], - }), + vite_theme_plugin, antdDarkThemePlugin({ preloadFiles: [ path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'), @@ -58,6 +74,7 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] { // #8b949e 'text-color-secondary': '#8b949e', 'border-color-base': '#303030', + 'header-light-bottom-border-color': '#303030', // 'border-color-split': '#30363d', 'item-active-bg': '#111b26', 'app-content-background': '#1e1e1e',