Skip to content

Commit 41e470e

Browse files
committed
refactor(projects): refactor addThemeVarsToHtml
1 parent 2f15a2a commit 41e470e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/store/modules/theme/shared.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { GlobalThemeOverrides } from 'naive-ui';
22
import { getColorByColorPaletteNumber, getColorPalette } from '@sa/color-palette';
33
import { addColorAlpha, getRgbOfColor } from '@sa/utils';
4-
import { useStyleTag } from '@vueuse/core';
54
import { overrideThemeSettings, themeSettings } from '@/theme/settings';
65
import { themeVars } from '@/theme/vars';
76
import { localStg } from '@/utils/storage';
@@ -130,7 +129,6 @@ function getCssVarByTokens(tokens: App.Theme.BaseToken) {
130129
return styleStr;
131130
}
132131

133-
const { css: themeVarCss } = useStyleTag('', { id: 'theme-var-css' });
134132
/**
135133
* Add theme vars to html
136134
*
@@ -152,7 +150,15 @@ export function addThemeVarsToHtml(tokens: App.Theme.BaseToken, darkTokens: App.
152150
}
153151
`;
154152

155-
themeVarCss.value = css + darkCss;
153+
const styleId = 'theme-vars';
154+
155+
const style = document.querySelector(`#${styleId}`) || document.createElement('style');
156+
157+
style.id = styleId;
158+
159+
style.textContent = css + darkCss;
160+
161+
document.head.appendChild(style);
156162
}
157163

158164
/**

0 commit comments

Comments
 (0)