mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-22 13:40:16 +09:00
feat: clear indexDB
This commit is contained in:
parent
492b55c893
commit
0b758941a4
@ -27,7 +27,7 @@ import { createPersistStore } from "../utils/store";
|
|||||||
import { collectModelsWithDefaultModel } from "../utils/model";
|
import { collectModelsWithDefaultModel } from "../utils/model";
|
||||||
import { useAccessStore } from "./access";
|
import { useAccessStore } from "./access";
|
||||||
import { isDalle3 } from "../utils";
|
import { isDalle3 } from "../utils";
|
||||||
import { clear } from "idb-keyval";
|
import { indexDBStorage } from "@/app/utils/indexDB-storage";
|
||||||
|
|
||||||
export type ChatMessage = RequestMessage & {
|
export type ChatMessage = RequestMessage & {
|
||||||
date: string;
|
date: string;
|
||||||
@ -667,7 +667,7 @@ export const useChatStore = createPersistStore(
|
|||||||
},
|
},
|
||||||
|
|
||||||
async clearAllData() {
|
async clearAllData() {
|
||||||
await clear();
|
await indexDBStorage.clear();
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
location.reload();
|
location.reload();
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { StateStorage } from "zustand/middleware";
|
import { StateStorage } from "zustand/middleware";
|
||||||
import { get, set, del } from "idb-keyval";
|
import { get, set, del, clear } from "idb-keyval";
|
||||||
|
|
||||||
class IndexDBStorage implements StateStorage {
|
class IndexDBStorage implements StateStorage {
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
public async getItem(name: string): Promise<string | null> {
|
public async getItem(name: string): Promise<string | null> {
|
||||||
return (await get(name)) || localStorage.getItem(name);
|
return (await get(name)) || localStorage.getItem(name);
|
||||||
}
|
}
|
||||||
@ -15,6 +13,10 @@ class IndexDBStorage implements StateStorage {
|
|||||||
public async removeItem(name: string): Promise<void> {
|
public async removeItem(name: string): Promise<void> {
|
||||||
await del(name);
|
await del(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async clear(): Promise<void> {
|
||||||
|
await clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const indexDBStorage = new IndexDBStorage();
|
export const indexDBStorage = new IndexDBStorage();
|
||||||
|
Loading…
Reference in New Issue
Block a user