diff --git a/src/constant/cacheKeys.ts b/src/constants/cacheKey.ts similarity index 72% rename from src/constant/cacheKeys.ts rename to src/constants/cacheKey.ts index b6ead2a..c07b1b1 100644 --- a/src/constant/cacheKeys.ts +++ b/src/constants/cacheKey.ts @@ -1,10 +1,10 @@ const SYSTEM_NAME = "v3-admin-vite" -/** 缓存数据时用到的 Keys */ -class CacheKeys { +/** 缓存数据时用到的 Key */ +class CacheKey { static TOKEN = `${SYSTEM_NAME}-token-key` static SIDEBAR_STATUS = `${SYSTEM_NAME}-sidebar-status-key` static ACTIVE_THEME_NAME = `${SYSTEM_NAME}-active-theme-name-key` } -export default CacheKeys +export default CacheKey diff --git a/src/utils/cache/cookies.ts b/src/utils/cache/cookies.ts index b723fcc..b13f84b 100644 --- a/src/utils/cache/cookies.ts +++ b/src/utils/cache/cookies.ts @@ -1,8 +1,8 @@ /** 统一处理 Cookie */ -import CacheKeys from "@/constant/cacheKeys" +import CacheKey from "@/constants/cacheKey" import Cookies from "js-cookie" -export const getToken = () => Cookies.get(CacheKeys.TOKEN) -export const setToken = (token: string) => Cookies.set(CacheKeys.TOKEN, token) -export const removeToken = () => Cookies.remove(CacheKeys.TOKEN) +export const getToken = () => Cookies.get(CacheKey.TOKEN) +export const setToken = (token: string) => Cookies.set(CacheKey.TOKEN, token) +export const removeToken = () => Cookies.remove(CacheKey.TOKEN) diff --git a/src/utils/cache/localStorage.ts b/src/utils/cache/localStorage.ts index faf55e5..5bcedd4 100644 --- a/src/utils/cache/localStorage.ts +++ b/src/utils/cache/localStorage.ts @@ -1,9 +1,9 @@ /** 统一处理 localStorage */ -import CacheKeys from "@/constant/cacheKeys" +import CacheKey from "@/constants/cacheKey" -export const getSidebarStatus = () => localStorage.getItem(CacheKeys.SIDEBAR_STATUS) -export const setSidebarStatus = (sidebarStatus: string) => localStorage.setItem(CacheKeys.SIDEBAR_STATUS, sidebarStatus) +export const getSidebarStatus = () => localStorage.getItem(CacheKey.SIDEBAR_STATUS) +export const setSidebarStatus = (sidebarStatus: string) => localStorage.setItem(CacheKey.SIDEBAR_STATUS, sidebarStatus) -export const getActiveThemeName = () => localStorage.getItem(CacheKeys.ACTIVE_THEME_NAME) -export const setActiveThemeName = (themeName: string) => localStorage.setItem(CacheKeys.ACTIVE_THEME_NAME, themeName) +export const getActiveThemeName = () => localStorage.getItem(CacheKey.ACTIVE_THEME_NAME) +export const setActiveThemeName = (themeName: string) => localStorage.setItem(CacheKey.ACTIVE_THEME_NAME, themeName)