feat: clear indexDB

This commit is contained in:
Dogtiti
2024-08-26 21:23:21 +08:00
parent 492b55c893
commit 0b758941a4
2 changed files with 7 additions and 5 deletions

View File

@@ -1,9 +1,7 @@
import { StateStorage } from "zustand/middleware";
import { get, set, del } from "idb-keyval";
import { get, set, del, clear } from "idb-keyval";
class IndexDBStorage implements StateStorage {
constructor() {}
public async getItem(name: string): Promise<string | null> {
return (await get(name)) || localStorage.getItem(name);
}
@@ -15,6 +13,10 @@ class IndexDBStorage implements StateStorage {
public async removeItem(name: string): Promise<void> {
await del(name);
}
public async clear(): Promise<void> {
await clear();
}
}
export const indexDBStorage = new IndexDBStorage();