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,6 +1,6 @@
import { defineStore } from 'pinia';
import { darkTheme } from 'naive-ui';
import { getThemeSettings, getNaiveThemeOverrides, addThemeCssVarsToHtml } from './helpers';
import { getThemeSettings, getNaiveThemeOverrides } from './helpers';
type ThemeState = Theme.Setting;
@ -10,9 +10,6 @@ export const useThemeStore = defineStore('theme-store', {
/** naiveUI的主题配置 */
naiveThemeOverrides(state) {
const overrides = getNaiveThemeOverrides({ primary: state.themeColor, ...state.otherColor });
if (overrides.common) {
addThemeCssVarsToHtml(overrides.common);
}
return overrides;
},
/** naive-ui暗黑主题 */