update 后台跳转大屏免登录,优化登录数据缓存
This commit is contained in:
+5
-5
@@ -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
@@ -18,4 +18,9 @@ export function isJSON(str) {
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//是否为对象或数组
|
||||
export function isObjectOrArray(obj) {
|
||||
return isObject(obj) || isArray(obj);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user