mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-10-14 05:43:41 +08:00
refactor(projects): new storage system [新的本地数据存储系统]
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
import type { GlobalThemeOverrides } from 'naive-ui';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { themeSetting } from '@/settings';
|
||||
import { EnumStorageKey } from '@/enum';
|
||||
import { addColorAlpha, getColorPalette, getLocal, getThemeColor, removeLocal, setLocal } from '@/utils';
|
||||
import { localStg, addColorAlpha, getColorPalette } from '@/utils';
|
||||
|
||||
/** 初始化主题配置 */
|
||||
export function initThemeSettings() {
|
||||
const isProd = import.meta.env.PROD;
|
||||
// 生产环境才缓存主题配置,本地开发实时调整配置更改配置的json
|
||||
const storageSettings = getThemeSettings();
|
||||
const storageSettings = localStg.get('themeSettings');
|
||||
if (isProd && storageSettings) {
|
||||
return storageSettings;
|
||||
}
|
||||
|
||||
const themeColor = getThemeColor() || themeSetting.themeColor;
|
||||
const themeColor = localStg.get('themeColor') || themeSetting.themeColor;
|
||||
const info = themeSetting.isCustomizeInfoColor ? themeSetting.otherColor.info : getColorPalette(themeColor, 7);
|
||||
const otherColor = { ...themeSetting.otherColor, info };
|
||||
const setting = cloneDeep({ ...themeSetting, themeColor, otherColor });
|
||||
@@ -78,18 +77,3 @@ export function getNaiveThemeOverrides(colors: Record<ColorType, string>): Globa
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** 获取缓存中的主题配置 */
|
||||
function getThemeSettings() {
|
||||
return getLocal<Theme.Setting>(EnumStorageKey['theme-settings']);
|
||||
}
|
||||
|
||||
/** 获取缓存中的主题配置 */
|
||||
export function setThemeSettings(settings: Theme.Setting) {
|
||||
return setLocal(EnumStorageKey['theme-settings'], settings);
|
||||
}
|
||||
|
||||
/** 清除缓存配置 */
|
||||
export function clearThemeSettings() {
|
||||
removeLocal(EnumStorageKey['theme-settings']);
|
||||
}
|
||||
|
Reference in New Issue
Block a user