style: cache & constants
This commit is contained in:
parent
3f8fa531af
commit
ae4a77bec2
@ -1,10 +1,10 @@
|
|||||||
const SYSTEM_NAME = "v3-admin-vite"
|
const SYSTEM_NAME = "v3-admin-vite"
|
||||||
|
|
||||||
/** 缓存数据时用到的 Keys */
|
/** 缓存数据时用到的 Key */
|
||||||
class CacheKeys {
|
class CacheKey {
|
||||||
static TOKEN = `${SYSTEM_NAME}-token-key`
|
static TOKEN = `${SYSTEM_NAME}-token-key`
|
||||||
static SIDEBAR_STATUS = `${SYSTEM_NAME}-sidebar-status-key`
|
static SIDEBAR_STATUS = `${SYSTEM_NAME}-sidebar-status-key`
|
||||||
static ACTIVE_THEME_NAME = `${SYSTEM_NAME}-active-theme-name-key`
|
static ACTIVE_THEME_NAME = `${SYSTEM_NAME}-active-theme-name-key`
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CacheKeys
|
export default CacheKey
|
8
src/utils/cache/cookies.ts
vendored
8
src/utils/cache/cookies.ts
vendored
@ -1,8 +1,8 @@
|
|||||||
/** 统一处理 Cookie */
|
/** 统一处理 Cookie */
|
||||||
|
|
||||||
import CacheKeys from "@/constant/cacheKeys"
|
import CacheKey from "@/constants/cacheKey"
|
||||||
import Cookies from "js-cookie"
|
import Cookies from "js-cookie"
|
||||||
|
|
||||||
export const getToken = () => Cookies.get(CacheKeys.TOKEN)
|
export const getToken = () => Cookies.get(CacheKey.TOKEN)
|
||||||
export const setToken = (token: string) => Cookies.set(CacheKeys.TOKEN, token)
|
export const setToken = (token: string) => Cookies.set(CacheKey.TOKEN, token)
|
||||||
export const removeToken = () => Cookies.remove(CacheKeys.TOKEN)
|
export const removeToken = () => Cookies.remove(CacheKey.TOKEN)
|
||||||
|
10
src/utils/cache/localStorage.ts
vendored
10
src/utils/cache/localStorage.ts
vendored
@ -1,9 +1,9 @@
|
|||||||
/** 统一处理 localStorage */
|
/** 统一处理 localStorage */
|
||||||
|
|
||||||
import CacheKeys from "@/constant/cacheKeys"
|
import CacheKey from "@/constants/cacheKey"
|
||||||
|
|
||||||
export const getSidebarStatus = () => localStorage.getItem(CacheKeys.SIDEBAR_STATUS)
|
export const getSidebarStatus = () => localStorage.getItem(CacheKey.SIDEBAR_STATUS)
|
||||||
export const setSidebarStatus = (sidebarStatus: string) => localStorage.setItem(CacheKeys.SIDEBAR_STATUS, sidebarStatus)
|
export const setSidebarStatus = (sidebarStatus: string) => localStorage.setItem(CacheKey.SIDEBAR_STATUS, sidebarStatus)
|
||||||
|
|
||||||
export const getActiveThemeName = () => localStorage.getItem(CacheKeys.ACTIVE_THEME_NAME)
|
export const getActiveThemeName = () => localStorage.getItem(CacheKey.ACTIVE_THEME_NAME)
|
||||||
export const setActiveThemeName = (themeName: string) => localStorage.setItem(CacheKeys.ACTIVE_THEME_NAME, themeName)
|
export const setActiveThemeName = (themeName: string) => localStorage.setItem(CacheKey.ACTIVE_THEME_NAME, themeName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user