Merge pull request #377 from yanbowe/main

fix(styles): fix css var is inserted repeatedly
This commit is contained in:
Soybean 2024-04-07 17:41:08 +08:00 committed by GitHub
commit d9410e416e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
import type { GlobalThemeOverrides } from 'naive-ui';
import { getColorByColorPaletteNumber, getColorPalette } from '@sa/color-palette';
import { addColorAlpha, getRgbOfColor } from '@sa/utils';
import { useStyleTag } from '@vueuse/core';
import { overrideThemeSettings, themeSettings } from '@/theme/settings';
import { themeVars } from '@/theme/vars';
import { localStg } from '@/utils/storage';
@ -129,6 +130,7 @@ function getCssVarByTokens(tokens: App.Theme.BaseToken) {
return styleStr;
}
const { css: themeVarCss } = useStyleTag('', { id: 'theme-var-css' });
/**
* Add theme vars to html
*
@ -150,11 +152,7 @@ export function addThemeVarsToHtml(tokens: App.Theme.BaseToken, darkTokens: App.
}
`;
const style = document.createElement('style');
style.textContent = css + darkCss;
document.head.appendChild(style);
themeVarCss.value = css + darkCss;
}
/**