This commit is contained in:
Dede Fuji Abdul
2023-10-16 14:29:26 +07:00
parent 4ee87a0aa9
commit d80e8d2b5a
9 changed files with 979 additions and 96 deletions

28
src/stores/storage.ts Normal file
View 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
}