jdcProject_front/src/utils/cache/localStorage.ts

19 lines
607 B
TypeScript
Raw Normal View History

2022-08-19 21:13:41 +08:00
/** 统一处理 localStorage */
2022-08-22 14:30:08 +08:00
import CacheKey from "@/constants/cacheKey"
import type { ThemeName } from "@/hooks/useTheme"
2022-08-19 21:13:41 +08:00
2022-08-24 16:52:01 +08:00
export const getSidebarStatus = () => {
return localStorage.getItem(CacheKey.SIDEBAR_STATUS)
}
export const setSidebarStatus = (sidebarStatus: "opened" | "closed") => {
localStorage.setItem(CacheKey.SIDEBAR_STATUS, sidebarStatus)
}
2022-08-19 21:13:41 +08:00
2022-08-24 16:52:01 +08:00
export const getActiveThemeName = () => {
return localStorage.getItem(CacheKey.ACTIVE_THEME_NAME) as ThemeName
}
export const setActiveThemeName = (themeName: ThemeName) => {
localStorage.setItem(CacheKey.ACTIVE_THEME_NAME, themeName)
}