update
This commit is contained in:
28
src/utils/storage.ts
Normal file
28
src/utils/storage.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { EncryptStorage } from 'encrypt-storage'
|
||||
const encryptStorage = new EncryptStorage('qwertyuiopasdfghjklzxcvbnm-1234567890')
|
||||
|
||||
const writeData = (key: string, data: any) => encryptStorage.setItem(key, data)
|
||||
const writeDataJson = (key: string, data: any) => encryptStorage.setItem(key, JSON.stringify(data))
|
||||
const removeData = (key: string) => encryptStorage.removeItem(key)
|
||||
const readData = (key: string) => {
|
||||
try {
|
||||
return encryptStorage.getItem(key)
|
||||
} catch (error) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
const readDataJson = (key: string) => {
|
||||
try {
|
||||
return encryptStorage.getItem(key)
|
||||
} catch (error) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
removeData,
|
||||
writeData,
|
||||
writeDataJson,
|
||||
readData,
|
||||
readDataJson
|
||||
}
|
Reference in New Issue
Block a user