From 7e6b8b1eef198ab4de9633288037a23817f9ee39 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期三, 24 五月 2023 22:52:42 +0800
Subject: [PATCH] 45
---
src/utils/storage.ts | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/utils/storage.ts b/src/utils/storage.ts
index 8dbc873..bc3f3bd 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,26 @@
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) {
+ console.log(Cookies.get(key),key)
+ 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