打包后黑色主题下菜单tab标签不跟随系统主题颜色变化,开发模式下没问题 #1115
parent
cc67661f11
commit
8d984846af
|
@ -35,6 +35,11 @@
|
||||||
if (newValue === ThemeEnum.DARK) {
|
if (newValue === ThemeEnum.DARK) {
|
||||||
appTheme.value.algorithm = theme.darkAlgorithm;
|
appTheme.value.algorithm = theme.darkAlgorithm;
|
||||||
}
|
}
|
||||||
|
// update-begin--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
|
||||||
|
if (import.meta.env.PROD) {
|
||||||
|
changeTheme(appStore.getProjectConfig.themeColor);
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
|
||||||
appTheme.value = {
|
appTheme.value = {
|
||||||
...appTheme.value,
|
...appTheme.value,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
import { getThemeColors, generateColors } from '../../../build/config/themeConfig';
|
import { getThemeColors, generateColors } from '../../../build/config/themeConfig';
|
||||||
|
import {
|
||||||
import { replaceStyleVariables } from '@rys-fe/vite-plugin-theme/es/client';
|
replaceStyleVariables,
|
||||||
|
loadDarkThemeCss,
|
||||||
|
replaceCssColors,
|
||||||
|
darkCssIsReady,
|
||||||
|
linkID,
|
||||||
|
styleTagId,
|
||||||
|
appendCssToDom,
|
||||||
|
getStyleDom,
|
||||||
|
} from '@rys-fe/vite-plugin-theme/es/client';
|
||||||
import { mixLighten, mixDarken, tinycolor } from '@rys-fe/vite-plugin-theme/es/colorUtils';
|
import { mixLighten, mixDarken, tinycolor } from '@rys-fe/vite-plugin-theme/es/colorUtils';
|
||||||
import { useAppStore } from '/@/store/modules/app';
|
import { useAppStore } from '/@/store/modules/app';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
|
||||||
|
let cssText = '';
|
||||||
export async function changeTheme(color: string) {
|
export async function changeTheme(color: string) {
|
||||||
// update-begin--author:liaozhiyang---date:20231218---for:【QQYUN-6366】升级到antd4.x
|
// update-begin--author:liaozhiyang---date:20231218---for:【QQYUN-6366】升级到antd4.x
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
@ -16,17 +25,32 @@ export async function changeTheme(color: string) {
|
||||||
tinycolor,
|
tinycolor,
|
||||||
color,
|
color,
|
||||||
});
|
});
|
||||||
|
// update-begin--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
|
||||||
let res = await replaceStyleVariables({
|
if (import.meta.env.PROD && appStore.getDarkMode === 'dark') {
|
||||||
|
if (!darkCssIsReady && !cssText) {
|
||||||
|
await loadDarkThemeCss();
|
||||||
|
}
|
||||||
|
const el: HTMLLinkElement = document.getElementById(linkID) as HTMLLinkElement;
|
||||||
|
if (el?.href) {
|
||||||
|
// cssText = await fetchCss(el.href) as string;
|
||||||
|
!cssText && (cssText = await defHttp.get({ url: el.href }, { isTransformResponse: false }));
|
||||||
|
const colorVariables = [...getThemeColors(color), ...colors];
|
||||||
|
const processCss = await replaceCssColors(cssText, colorVariables);
|
||||||
|
appendCssToDom(getStyleDom(styleTagId) as HTMLStyleElement, processCss);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await replaceStyleVariables({
|
||||||
colorVariables: [...getThemeColors(color), ...colors],
|
colorVariables: [...getThemeColors(color), ...colors],
|
||||||
});
|
});
|
||||||
fixDark();
|
fixDark();
|
||||||
return res;
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
|
||||||
}
|
}
|
||||||
|
|
||||||
// 【LOWCOD-2262】修复黑暗模式下切换皮肤无效的问题
|
// 【LOWCOD-2262】修复黑暗模式下切换皮肤无效的问题
|
||||||
async function fixDark() {
|
async function fixDark() {
|
||||||
let el = document.getElementById('__VITE_PLUGIN_THEME__');
|
// update-begin--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
|
||||||
|
const el = document.getElementById(styleTagId);
|
||||||
|
// update-end--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
|
||||||
if (el) {
|
if (el) {
|
||||||
el.innerHTML = el.innerHTML.replace(/\\["']dark\\["']/g, `'dark'`);
|
el.innerHTML = el.innerHTML.replace(/\\["']dark\\["']/g, `'dark'`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue