|
@@ -3,10 +3,6 @@ import { useAppStore } from '/@/store/modules/app';
|
|
|
import { ThemeEnum } from '/@/enums/appEnum';
|
|
|
import { setCssVar } from './util';
|
|
|
|
|
|
-const TEXT_COLOR_VAR = '--text-color';
|
|
|
-
|
|
|
-const BORDER_COLOR_VAR = '--border-color';
|
|
|
-
|
|
|
const HEADER_BG_COLOR_VAR = '--header-bg-color';
|
|
|
const HEADER_BG_HOVER_COLOR_VAR = '--header-bg-hover-color';
|
|
|
const HEADER_MENU_ACTIVE_BG_COLOR_VAR = '--header-active-menu-bg-color';
|
|
@@ -15,68 +11,6 @@ const SIDER_DARK_BG_COLOR = '--sider-dark-bg-color';
|
|
|
const SIDER_DARK_DARKEN_BG_COLOR = '--sider-dark-darken-bg-color';
|
|
|
const SIDER_LIGHTEN_BG_COLOR = '--sider-dark-lighten-bg-color';
|
|
|
|
|
|
-const COMPONENT_BACKGROUND_COLOR = '--component-background-color';
|
|
|
-
|
|
|
-const APP_CONTENT_BACKGROUND_COLOR = '--app-content-background-color';
|
|
|
-
|
|
|
-/**
|
|
|
- * Change the text color of the html
|
|
|
- * @param color
|
|
|
- */
|
|
|
-export function updateTextColor(color?: string) {
|
|
|
- const appStore = useAppStore();
|
|
|
- const darkMode = appStore.getDarkMode === ThemeEnum.DARK;
|
|
|
- if (!color) {
|
|
|
- if (darkMode) {
|
|
|
- color = '#c9d1d9';
|
|
|
- } else {
|
|
|
- color = 'rgb(0, 0, 0, 0.85)';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // text color
|
|
|
- setCssVar(TEXT_COLOR_VAR, color);
|
|
|
-
|
|
|
- // only #ffffff is light
|
|
|
- // Only when the background color is #fff, the theme of the menu will be changed to light
|
|
|
- const isLight = ['#fff', '#ffffff'].includes(color!.toLowerCase());
|
|
|
-
|
|
|
- appStore.setProjectConfig({
|
|
|
- menuSetting: {
|
|
|
- theme: isLight && !darkMode ? ThemeEnum.LIGHT : ThemeEnum.DARK,
|
|
|
- },
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Change the border color of the border
|
|
|
- * @param color
|
|
|
- */
|
|
|
-export function updateBorderColor(color?: string) {
|
|
|
- const appStore = useAppStore();
|
|
|
- const darkMode = appStore.getDarkMode === ThemeEnum.DARK;
|
|
|
- if (!color) {
|
|
|
- if (darkMode) {
|
|
|
- color = '#303030';
|
|
|
- } else {
|
|
|
- color = '#eee';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // text color
|
|
|
- setCssVar(BORDER_COLOR_VAR, color);
|
|
|
-
|
|
|
- // only #ffffff is light
|
|
|
- // Only when the background color is #fff, the theme of the menu will be changed to light
|
|
|
- const isLight = ['#fff', '#ffffff'].includes(color!.toLowerCase());
|
|
|
-
|
|
|
- appStore.setProjectConfig({
|
|
|
- menuSetting: {
|
|
|
- theme: isLight && !darkMode ? ThemeEnum.LIGHT : ThemeEnum.DARK,
|
|
|
- },
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Change the background color of the top header
|
|
|
* @param color
|
|
@@ -140,59 +74,3 @@ export function updateSidebarBgColor(color?: string) {
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
-/**
|
|
|
- * Change the background color of the componet
|
|
|
- * @param color
|
|
|
- */
|
|
|
-export function updateComponentBgColor(color?: string) {
|
|
|
- const appStore = useAppStore();
|
|
|
- const darkMode = appStore.getDarkMode === ThemeEnum.DARK;
|
|
|
- if (!color) {
|
|
|
- if (darkMode) {
|
|
|
- color = '#151515';
|
|
|
- } else {
|
|
|
- color = '#fff';
|
|
|
- }
|
|
|
- }
|
|
|
- // component color
|
|
|
- setCssVar(COMPONENT_BACKGROUND_COLOR, color);
|
|
|
-
|
|
|
- // only #ffffff is light
|
|
|
- // Only when the background color is #fff, the theme of the menu will be changed to light
|
|
|
- const isLight = ['#fff', '#ffffff'].includes(color!.toLowerCase());
|
|
|
-
|
|
|
- appStore.setProjectConfig({
|
|
|
- menuSetting: {
|
|
|
- theme: isLight && !darkMode ? ThemeEnum.LIGHT : ThemeEnum.DARK,
|
|
|
- },
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Change the background color of the app content
|
|
|
- * @param color
|
|
|
- */
|
|
|
-export function updateAppContentBgColor(color?: string) {
|
|
|
- const appStore = useAppStore();
|
|
|
- const darkMode = appStore.getDarkMode === ThemeEnum.DARK;
|
|
|
- if (!color) {
|
|
|
- if (darkMode) {
|
|
|
- color = '#1e1e1e';
|
|
|
- } else {
|
|
|
- color = '#fafafa';
|
|
|
- }
|
|
|
- }
|
|
|
- // app content color
|
|
|
- setCssVar(APP_CONTENT_BACKGROUND_COLOR, color);
|
|
|
-
|
|
|
- // only #ffffff is light
|
|
|
- // Only when the background color is #fff, the theme of the menu will be changed to light
|
|
|
- const isLight = ['#fff', '#ffffff'].includes(color!.toLowerCase());
|
|
|
-
|
|
|
- appStore.setProjectConfig({
|
|
|
- menuSetting: {
|
|
|
- theme: isLight && !darkMode ? ThemeEnum.LIGHT : ThemeEnum.DARK,
|
|
|
- },
|
|
|
- });
|
|
|
-}
|