feat(projects): 添加缓存主题色

This commit is contained in:
Soybean
2022-01-22 00:48:17 +08:00
parent 1d63a83822
commit 37092974d3
15 changed files with 87 additions and 34 deletions

View File

@ -136,3 +136,11 @@ export function addColorAlpha(color: string, alpha: number) {
export function mixColor(firstColor: string, secondColor: string, ratio: number) {
return colord(firstColor).mix(secondColor, ratio).toHex();
}
/**
* 是否是白颜色
* @param color - 颜色
*/
export function isWhiteColor(color: string) {
return colord(color).isEqual('#ffffff');
}

View File

@ -5,3 +5,4 @@ export * from './number';
export * from './object';
export * from './icon';
export * from './design-pattern';
export * from './theme';

16
src/utils/common/theme.ts Normal file
View File

@ -0,0 +1,16 @@
import { EnumStorageKey } from '@/enum';
/**
* 缓存主题颜色
* @param color
*/
export function setThemeColor(color: string) {
window.localStorage.setItem(EnumStorageKey['theme-color'], color);
}
/**
* 获取缓存的主题颜色
*/
export function getThemeColor() {
return window.localStorage.getItem(EnumStorageKey['theme-color']);
}