|
@@ -1,11 +1,12 @@
|
|
|
-import { toBase64, parseBase64 } from './base64/index';
|
|
|
|
|
import { ErrorCodeList } from '@/services/dataCenter/interafce/error';
|
|
import { ErrorCodeList } from '@/services/dataCenter/interafce/error';
|
|
|
-interface storageKeyName {
|
|
|
|
|
|
|
+import { parseBase64, toBase64 } from './base64/index';
|
|
|
|
|
+interface StorageKeyName {
|
|
|
loginData: string; // 账号登录返回信息 token等
|
|
loginData: string; // 账号登录返回信息 token等
|
|
|
loginAccount: string; // 登录账号信息 用来多窗口
|
|
loginAccount: string; // 登录账号信息 用来多窗口
|
|
|
bankSignDetail: string; // 银行签约信息详情
|
|
bankSignDetail: string; // 银行签约信息详情
|
|
|
cusBank: string; // 托管银行
|
|
cusBank: string; // 托管银行
|
|
|
ErrorInfos: string; // 数据库错误信息
|
|
ErrorInfos: string; // 数据库错误信息
|
|
|
|
|
+ allEnums: string; // 所有枚举信息
|
|
|
errorCodeInfos: ErrorCodeList[];
|
|
errorCodeInfos: ErrorCodeList[];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -19,7 +20,7 @@ class LocalStorage {
|
|
|
* @param key 数据项名
|
|
* @param key 数据项名
|
|
|
* @param value 数据项值
|
|
* @param value 数据项值
|
|
|
*/
|
|
*/
|
|
|
- setItem(key: keyof storageKeyName, value: any): void {
|
|
|
|
|
|
|
+ setItem(key: keyof StorageKeyName, value: any): void {
|
|
|
localStorage.setItem(toBase64(key), toBase64(value));
|
|
localStorage.setItem(toBase64(key), toBase64(value));
|
|
|
if (!this.cacheKey.includes(key)) {
|
|
if (!this.cacheKey.includes(key)) {
|
|
|
this.cacheKey.push(key);
|
|
this.cacheKey.push(key);
|
|
@@ -29,14 +30,14 @@ class LocalStorage {
|
|
|
* 移除 localStorage 项
|
|
* 移除 localStorage 项
|
|
|
* @param key 移除项名
|
|
* @param key 移除项名
|
|
|
*/
|
|
*/
|
|
|
- removeItem(key: keyof storageKeyName): void {
|
|
|
|
|
|
|
+ removeItem(key: keyof StorageKeyName): void {
|
|
|
localStorage.removeItem(toBase64(key));
|
|
localStorage.removeItem(toBase64(key));
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 读取 localStorage 项
|
|
* 读取 localStorage 项
|
|
|
* @param key 读取项名
|
|
* @param key 读取项名
|
|
|
*/
|
|
*/
|
|
|
- getItem(key: keyof storageKeyName): any {
|
|
|
|
|
|
|
+ getItem(key: keyof StorageKeyName): any {
|
|
|
const value = localStorage.getItem(toBase64(key)) as string;
|
|
const value = localStorage.getItem(toBase64(key)) as string;
|
|
|
return value && parseBase64(value);
|
|
return value && parseBase64(value);
|
|
|
}
|
|
}
|
|
@@ -44,7 +45,7 @@ class LocalStorage {
|
|
|
* 清空本项目LocalStorage中所有成员
|
|
* 清空本项目LocalStorage中所有成员
|
|
|
*/
|
|
*/
|
|
|
clear(): void {
|
|
clear(): void {
|
|
|
- this.cacheKey.forEach((e) => this.removeItem(e as keyof storageKeyName));
|
|
|
|
|
|
|
+ this.cacheKey.forEach((e) => this.removeItem(e as keyof StorageKeyName));
|
|
|
this.cacheKey.length = 0;
|
|
this.cacheKey.length = 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|