mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-20 10:36:38 +08:00
refactor(projects): refactor addThemeVarsToHtml
This commit is contained in:
parent
2f15a2ac6a
commit
41e470ed6e
@ -1,7 +1,6 @@
|
|||||||
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';
|
||||||
@ -130,7 +129,6 @@ 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
|
||||||
*
|
*
|
||||||
@ -152,7 +150,15 @@ export function addThemeVarsToHtml(tokens: App.Theme.BaseToken, darkTokens: App.
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
themeVarCss.value = css + darkCss;
|
const styleId = 'theme-vars';
|
||||||
|
|
||||||
|
const style = document.querySelector(`#${styleId}`) || document.createElement('style');
|
||||||
|
|
||||||
|
style.id = styleId;
|
||||||
|
|
||||||
|
style.textContent = css + darkCss;
|
||||||
|
|
||||||
|
document.head.appendChild(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user