chore:更换到主分支

This commit is contained in:
张益铭
2021-03-01 15:26:05 +08:00
parent 9064b372e8
commit 6a5f1810f9
3530 changed files with 59613 additions and 479452 deletions

View File

@@ -0,0 +1,42 @@
interface ProxyStorage {
getItem(key: string): any
setItem(Key: string, value: string): void
removeItem(key: string): void
}
//sessionStorage operate
class sessionStorageProxy implements ProxyStorage {
protected storage: ProxyStorage
constructor(storageModel: ProxyStorage) {
this.storage = storageModel
}
// 存
public setItem(key: string, value: any): void {
this.storage.setItem(key, JSON.stringify(value))
}
// 取
public getItem(key: string): any {
return JSON.parse(this.storage.getItem(key)) || null
}
// 删
public removeItem(key: string): void {
this.storage.removeItem(key)
}
}
//localStorage operate
class localStorageProxy extends sessionStorageProxy implements ProxyStorage {
constructor(localStorage: ProxyStorage) {
super(localStorage)
}
}
export const storageSession = new sessionStorageProxy(sessionStorage)
export const storageLocal = new localStorageProxy(localStorage)