mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-20 18:46:39 +08:00
fix(styles): fix css var is inserted repeatedly
This commit is contained in:
parent
0fbb00cee1
commit
769d84a7f4
@ -1,6 +1,7 @@
|
|||||||
import type { GlobalThemeOverrides } from 'naive-ui';
|
import type { GlobalThemeOverrides } from 'naive-ui';
|
||||||
import { getColorByColorPaletteNumber, getColorPalette } from '@sa/color-palette';
|
import { getColorByColorPaletteNumber, getColorPalette } from '@sa/color-palette';
|
||||||
import { addColorAlpha, getRgbOfColor } from '@sa/utils';
|
import { addColorAlpha, getRgbOfColor } from '@sa/utils';
|
||||||
|
import { useStyleTag } from '@vueuse/core';
|
||||||
import { overrideThemeSettings, themeSettings } from '@/theme/settings';
|
import { overrideThemeSettings, themeSettings } from '@/theme/settings';
|
||||||
import { themeVars } from '@/theme/vars';
|
import { themeVars } from '@/theme/vars';
|
||||||
import { localStg } from '@/utils/storage';
|
import { localStg } from '@/utils/storage';
|
||||||
@ -129,6 +130,7 @@ function getCssVarByTokens(tokens: App.Theme.BaseToken) {
|
|||||||
return styleStr;
|
return styleStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { css: themeVarCss } = useStyleTag('', { id: 'theme-var-css' });
|
||||||
/**
|
/**
|
||||||
* Add theme vars to html
|
* Add theme vars to html
|
||||||
*
|
*
|
||||||
@ -150,11 +152,7 @@ export function addThemeVarsToHtml(tokens: App.Theme.BaseToken, darkTokens: App.
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const style = document.createElement('style');
|
themeVarCss.value = css + darkCss;
|
||||||
|
|
||||||
style.textContent = css + darkCss;
|
|
||||||
|
|
||||||
document.head.appendChild(style);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user