Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-21 03:19:19 +08:00

style: cache & constants

This commit is contained in:
pany 2022-08-22 14:30:08 +08:00
parent 3f8fa531af
commit ae4a77bec2
3 changed files with 12 additions and 12 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)