From c2d879c83d5d242d32b376193e1a4680067d169c Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期三, 31 五月 2023 15:14:38 +0800
Subject: [PATCH] 优化逻辑
---
src/utils/storage.ts | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/utils/storage.ts b/src/utils/storage.ts
index 8dbc873..1ee4234 100644
--- a/src/utils/storage.ts
+++ b/src/utils/storage.ts
@@ -1,3 +1,5 @@
+
+import Cookies from 'js-cookie'
/**
* window.localStorage 浏览器永久缓存
* @method set 设置永久缓存
@@ -35,19 +37,25 @@
export const Session = {
// 设置临时缓存
set(key: string, val: any) {
+ console.log('设置临时缓存')
+ console.log(key,val)
+ if (key === 'token') return Cookies.set(key, val)
window.sessionStorage.setItem(key, JSON.stringify(val))
},
// 获取临时缓存
get(key: string) {
+ if (key === 'token') return Cookies.get(key)
const json: any = window.sessionStorage.getItem(key)
return JSON.parse(json)
},
// 移除临时缓存
remove(key: string) {
+ if (key === 'token') return Cookies.remove(key)
window.sessionStorage.removeItem(key)
},
// 移除全部临时缓存
clear() {
+ Cookies.remove('token')
window.sessionStorage.clear()
},
}
--
Gitblit v1.8.0