mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-02 08:06:38 +08:00
Merge remote-tracking branch 'upstream/main' into dev
This commit is contained in:
commit
8deb96985e
@ -30,6 +30,8 @@ One-Click to get a well-designed cross-platform ChatGPT web UI, with GPT3, GPT4
|
|||||||
|
|
||||||
[<img src="https://vercel.com/button" alt="Deploy on Zeabur" height="30">](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FChatGPTNextWeb%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=nextchat&repository-name=NextChat) [<img src="https://zeabur.com/button.svg" alt="Deploy on Zeabur" height="30">](https://zeabur.com/templates/ZBUEFA) [<img src="https://gitpod.io/button/open-in-gitpod.svg" alt="Open in Gitpod" height="30">](https://gitpod.io/#https://github.com/Yidadaa/ChatGPT-Next-Web)
|
[<img src="https://vercel.com/button" alt="Deploy on Zeabur" height="30">](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FChatGPTNextWeb%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=nextchat&repository-name=NextChat) [<img src="https://zeabur.com/button.svg" alt="Deploy on Zeabur" height="30">](https://zeabur.com/templates/ZBUEFA) [<img src="https://gitpod.io/button/open-in-gitpod.svg" alt="Open in Gitpod" height="30">](https://gitpod.io/#https://github.com/Yidadaa/ChatGPT-Next-Web)
|
||||||
|
|
||||||
|
[<img src="https://github.com/user-attachments/assets/903482d4-3e87-4134-9af1-f2588fa90659" height="60" width="288" >](https://monica.im/?utm=nxcrp)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Enterprise Edition
|
## Enterprise Edition
|
||||||
|
@ -32,6 +32,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 { indexedDBStorage } from "@/app/utils/indexedDB-storage";
|
||||||
|
|
||||||
export type ChatMessage = RequestMessage & {
|
export type ChatMessage = RequestMessage & {
|
||||||
date: string;
|
date: string;
|
||||||
@ -1023,7 +1024,8 @@ export const useChatStore = createPersistStore(
|
|||||||
set(() => ({ sessions }));
|
set(() => ({ sessions }));
|
||||||
},
|
},
|
||||||
|
|
||||||
clearAllData() {
|
async clearAllData() {
|
||||||
|
await indexedDBStorage.clear();
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
location.reload();
|
location.reload();
|
||||||
},
|
},
|
||||||
|
38
app/utils/indexedDB-storage.ts
Normal file
38
app/utils/indexedDB-storage.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { StateStorage } from "zustand/middleware";
|
||||||
|
import { get, set, del, clear } from "idb-keyval";
|
||||||
|
|
||||||
|
class IndexedDBStorage implements StateStorage {
|
||||||
|
public async getItem(name: string): Promise<string | null> {
|
||||||
|
try {
|
||||||
|
return (await get(name)) || localStorage.getItem(name);
|
||||||
|
} catch (error) {
|
||||||
|
return localStorage.getItem(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async setItem(name: string, value: string): Promise<void> {
|
||||||
|
try {
|
||||||
|
await set(name, value);
|
||||||
|
} catch (error) {
|
||||||
|
localStorage.setItem(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async removeItem(name: string): Promise<void> {
|
||||||
|
try {
|
||||||
|
await del(name);
|
||||||
|
} catch (error) {
|
||||||
|
localStorage.removeItem(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async clear(): Promise<void> {
|
||||||
|
try {
|
||||||
|
await clear();
|
||||||
|
} catch (error) {
|
||||||
|
localStorage.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const indexedDBStorage = new IndexedDBStorage();
|
@ -1,7 +1,8 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { combine, persist } from "zustand/middleware";
|
import { combine, persist, createJSONStorage } from "zustand/middleware";
|
||||||
import { Updater } from "../typing";
|
import { Updater } from "../typing";
|
||||||
import { deepClone } from "./clone";
|
import { deepClone } from "./clone";
|
||||||
|
import { indexedDBStorage } from "@/app/utils/indexedDB-storage";
|
||||||
|
|
||||||
type SecondParam<T> = T extends (
|
type SecondParam<T> = T extends (
|
||||||
_f: infer _F,
|
_f: infer _F,
|
||||||
@ -31,6 +32,7 @@ export function createPersistStore<T extends object, M>(
|
|||||||
) => M,
|
) => M,
|
||||||
persistOptions: SecondParam<typeof persist<T & M & MakeUpdater<T>>>,
|
persistOptions: SecondParam<typeof persist<T & M & MakeUpdater<T>>>,
|
||||||
) {
|
) {
|
||||||
|
persistOptions.storage = createJSONStorage(() => indexedDBStorage);
|
||||||
return create(
|
return create(
|
||||||
persist(
|
persist(
|
||||||
combine(
|
combine(
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
"fuse.js": "^7.0.0",
|
"fuse.js": "^7.0.0",
|
||||||
"heic2any": "^0.0.4",
|
"heic2any": "^0.0.4",
|
||||||
"html-to-image": "^1.11.11",
|
"html-to-image": "^1.11.11",
|
||||||
|
"idb-keyval": "^6.2.1",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"mermaid": "^10.7.0",
|
"mermaid": "^10.7.0",
|
||||||
"microsoft-cognitiveservices-speech-sdk": "^1.36.0",
|
"microsoft-cognitiveservices-speech-sdk": "^1.36.0",
|
||||||
|
@ -4877,6 +4877,11 @@ iconv-lite@0.6:
|
|||||||
dependencies:
|
dependencies:
|
||||||
safer-buffer ">= 2.1.2 < 3.0.0"
|
safer-buffer ">= 2.1.2 < 3.0.0"
|
||||||
|
|
||||||
|
idb-keyval@^6.2.1:
|
||||||
|
version "6.2.1"
|
||||||
|
resolved "https://registry.npmmirror.com/idb-keyval/-/idb-keyval-6.2.1.tgz#94516d625346d16f56f3b33855da11bfded2db33"
|
||||||
|
integrity sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg==
|
||||||
|
|
||||||
ignore@^5.2.0:
|
ignore@^5.2.0:
|
||||||
version "5.3.1"
|
version "5.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef"
|
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef"
|
||||||
|
Loading…
Reference in New Issue
Block a user