| 1 | import type { StateStorage } from 'zustand/middleware' |
| 2 | |
| 3 | class AppLocalStorage implements StateStorage { |
| 4 | public async getItem(name: string): Promise<string | null> { |
| 5 | if (typeof window === 'undefined') |
| 6 | return null |
| 7 | return localStorage.getItem(name) |
| 8 | } |
| 9 | |
| 10 | public async setItem(name: string, value: string): Promise<void> { |
| 11 | if (typeof window === 'undefined') |
| 12 | return |
| 13 | localStorage.setItem(name, value) |
| 14 | } |
| 15 | |
| 16 | public async removeItem(name: string): Promise<void> { |
| 17 | if (typeof window === 'undefined') |
| 18 | return |
| 19 | localStorage.removeItem(name) |
| 20 | } |
| 21 | |
| 22 | public async clear(): Promise<void> { |
| 23 | // try { |
| 24 | // await clear(); |
| 25 | // } catch (error) { |
| 26 | // localStorage.clear(); |
| 27 | // } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | export const appLocalStorage = new AppLocalStorage() |
| 32 |