update 后台跳转大屏免登录,优化登录数据缓存

This commit is contained in:
zk
2024-05-18 15:16:10 +08:00
parent cb2a823d25
commit 6ff0b25f1b
8 changed files with 58 additions and 23 deletions
+5 -5
View File
@@ -1,4 +1,4 @@
import { isJSON } from '/@/utils/is.ts';
import { isJSON, isObjectOrArray } from '/@/utils/is.ts';
export function getAuthCache(key) {
let v = localStorage.getItem(key);
@@ -10,9 +10,9 @@ export function getAuthCache(key) {
}
export function setAuthCache(key, value) {
if (!isJSON(value)) {
return localStorage.setItem(key, value);
} else {
if (isObjectOrArray(value)) {
return localStorage.setItem(key, JSON.stringify(value));
} else {
return localStorage.setItem(key, value);
}
}
}
+6 -1
View File
@@ -18,4 +18,9 @@ export function isJSON(str) {
} catch (e) {
return false;
}
}
}
//是否为对象或数组
export function isObjectOrArray(obj) {
return isObject(obj) || isArray(obj);
}