2024-04-25 16:01:08: merge [main:7f9a52684105c7ff0a068812245c462ceb6d553e];
This commit is contained in:
1 parent
5a5f104174
commit
a31c44eb7b
121 files changed
+14802
-84
No files matched your search
@@ -0,0 +1,20 @@
|
||||
export const LocalStorage = {
|
||||
set(key: string, value: any): void {
|
||||
const item = typeof value === 'string' ? value : JSON.stringify(value)
|
||||
localStorage.setItem(key, item)
|
||||
},
|
||||
get(key: string): any | null {
|
||||
const value = localStorage.getItem(key)
|
||||
try {
|
||||
return value ? JSON.parse(value) : null
|
||||
} catch (error) {
|
||||
return value
|
||||
}
|
||||
},
|
||||
remove(key: string): void {
|
||||
localStorage.removeItem(key)
|
||||
},
|
||||
clear(): void {
|
||||
localStorage.clear()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user