jdcProject_front/src/utils/cache/localStorage.ts

19 lines
607 B
TypeScript

/** 统一处理 localStorage */
import CacheKey from "@/constants/cacheKey"
import type { ThemeName } from "@/hooks/useTheme"
export const getSidebarStatus = () => {
return localStorage.getItem(CacheKey.SIDEBAR_STATUS)
}
export const setSidebarStatus = (sidebarStatus: "opened" | "closed") => {
localStorage.setItem(CacheKey.SIDEBAR_STATUS, sidebarStatus)
}
export const getActiveThemeName = () => {
return localStorage.getItem(CacheKey.ACTIVE_THEME_NAME) as ThemeName
}
export const setActiveThemeName = (themeName: ThemeName) => {
localStorage.setItem(CacheKey.ACTIVE_THEME_NAME, themeName)
}