refactor(projects): 去除在pinia的getters的函数调用副作用,用watch代替

This commit is contained in:
Soybean
2022-04-21 00:43:17 +08:00
parent 24010d05fb
commit b35ed8960d
4 changed files with 49 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
import type { GlobalThemeOverrides } from 'naive-ui';
import { cloneDeep, kebabCase } from 'lodash-es';
import { cloneDeep } from 'lodash-es';
import { themeSetting } from '@/settings';
import { getThemeColor, getColorPalette, addColorAlpha } from '@/utils';
@@ -72,20 +72,6 @@ export function getNaiveThemeOverrides(colors: Record<ColorType, string>): Globa
};
}
type ThemeVars = Exclude<GlobalThemeOverrides['common'], undefined>;
type ThemeVarsKeys = keyof ThemeVars;
/** 添加css vars至html */
export function addThemeCssVarsToHtml(themeVars: ThemeVars) {
const keys = Object.keys(themeVars) as ThemeVarsKeys[];
const style: string[] = [];
keys.forEach(key => {
style.push(`--${kebabCase(key)}: ${themeVars[key]}`);
});
const styleStr = style.join(';');
document.documentElement.style.cssText += styleStr;
}
/** windicss 暗黑模式 */
export function handleWindicssDarkMode() {
const DARK_CLASS = 'dark';