feat(projects): 新增主题配置

This commit is contained in:
Soybean
2021-08-18 12:02:59 +08:00
parent 09a28d8e1d
commit ed67b797c2
30 changed files with 528 additions and 47 deletions

View File

@ -1,7 +1,13 @@
import { defineStore } from 'pinia';
import type { GlobalThemeOverrides } from 'naive-ui';
import { store } from '../../index';
import { themeSettings } from '@/settings';
import type { ThemeSettings } from '@/interface';
import { brightenColor } from '@/utils';
interface AppState {
/** 主题配置 */
themeSettings: ThemeSettings;
/** 侧边栏折叠 */
asideCollapse: boolean;
}
@ -9,8 +15,29 @@ interface AppState {
const appStore = defineStore({
id: 'app-store',
state: (): AppState => ({
themeSettings,
asideCollapse: false
}),
getters: {
/** naive UI主题配置 */
themeOverrids(): GlobalThemeOverrides {
const primaryColor = this.themeSettings.themeColor;
const primaryColorHover = brightenColor(primaryColor);
const primaryColorPressed = primaryColorHover;
const colorLoading = primaryColor;
return {
common: {
primaryColor,
primaryColorHover,
primaryColorPressed
},
LoadingBar: {
colorLoading
}
};
}
},
actions: {
handleAsideCollapse(collapse: boolean) {
this.asideCollapse = collapse;