修复编译后主题色切换不生效黑屏的问题
parent
e7b860181e
commit
6c2dfc29f2
|
@ -14,8 +14,11 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] {
|
||||||
mixLighten,
|
mixLighten,
|
||||||
tinycolor,
|
tinycolor,
|
||||||
});
|
});
|
||||||
const plugin = [
|
|
||||||
viteThemePlugin({
|
// update-begin-修复编译后主题色切换不生效黑屏的问题-----------------------
|
||||||
|
// https://github.com/vbenjs/vue-vben-admin/issues/1445
|
||||||
|
// 抽取出viteThemePlugin插件,下方会根据不同环境设置enforce
|
||||||
|
const vite_theme_plugin = viteThemePlugin({
|
||||||
resolveSelector: (s) => {
|
resolveSelector: (s) => {
|
||||||
s = s.trim();
|
s = s.trim();
|
||||||
switch (s) {
|
switch (s) {
|
||||||
|
@ -38,7 +41,20 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] {
|
||||||
return s.startsWith('[data-theme') ? s : `[data-theme] ${s}`;
|
return s.startsWith('[data-theme') ? s : `[data-theme] ${s}`;
|
||||||
},
|
},
|
||||||
colorVariables: [...getThemeColors(), ...colors],
|
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 = [
|
||||||
|
vite_theme_plugin,
|
||||||
antdDarkThemePlugin({
|
antdDarkThemePlugin({
|
||||||
preloadFiles: [
|
preloadFiles: [
|
||||||
path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'),
|
path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'),
|
||||||
|
@ -58,6 +74,7 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] {
|
||||||
// #8b949e
|
// #8b949e
|
||||||
'text-color-secondary': '#8b949e',
|
'text-color-secondary': '#8b949e',
|
||||||
'border-color-base': '#303030',
|
'border-color-base': '#303030',
|
||||||
|
'header-light-bottom-border-color': '#303030',
|
||||||
// 'border-color-split': '#30363d',
|
// 'border-color-split': '#30363d',
|
||||||
'item-active-bg': '#111b26',
|
'item-active-bg': '#111b26',
|
||||||
'app-content-background': '#1e1e1e',
|
'app-content-background': '#1e1e1e',
|
||||||
|
|
Loading…
Reference in New Issue