mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-16 22:13:47 +08:00
Compare commits
110 Commits
v2.14.2
...
97368f54dd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97368f54dd | ||
|
|
85704570f3 | ||
|
|
53dcae9e9c | ||
|
|
ed9aae531e | ||
|
|
886ffc0af8 | ||
|
|
f51a6a6b6e | ||
|
|
97a4a910e0 | ||
|
|
19c7a84548 | ||
|
|
488bf51b93 | ||
|
|
b6bb1673d4 | ||
|
|
7b6fe66f2a | ||
|
|
c2fc0b4979 | ||
|
|
0b758941a4 | ||
|
|
492b55c893 | ||
|
|
4060e367ad | ||
|
|
91b69c4fb7 | ||
|
|
718782f5b1 | ||
|
|
0c3fb5b2ce | ||
|
|
3be687a28a | ||
|
|
4ec6b067e7 | ||
|
|
1748dd6a3b | ||
|
|
95332e50ed | ||
|
|
8496980cf9 | ||
|
|
ffe32694b0 | ||
|
|
3d5b21154b | ||
|
|
4b9697e336 | ||
|
|
b0e9a542ba | ||
|
|
8b67536c23 | ||
|
|
cd49c12181 | ||
|
|
b2e364e6dd | ||
|
|
a6b14c7910 | ||
|
|
e275abdb9c | ||
|
|
09a90665d5 | ||
|
|
6649fbdfd0 | ||
|
|
64a0ffee7b | ||
|
|
b529118f31 | ||
|
|
39d7d9f13a | ||
|
|
fcd55df969 | ||
|
|
c5ab4d80d1 | ||
|
|
1e59948358 | ||
|
|
1102ef6e6b | ||
|
|
7ce2e8f4c4 | ||
|
|
fd1c656bdd | ||
|
|
82298a760a | ||
|
|
b84bb72e07 | ||
|
|
b9702a7902 | ||
|
|
09b56c9399 | ||
|
|
e3f499be0c | ||
|
|
4aae37b90c | ||
|
|
86220573b6 | ||
|
|
65ed6b02a4 | ||
|
|
98093a1f31 | ||
|
|
00990dc195 | ||
|
|
3da5284a07 | ||
|
|
cd920364f8 | ||
|
|
2565f5a398 | ||
|
|
2c0a73049d | ||
|
|
57a2ce222c | ||
|
|
76eb67d7ac | ||
|
|
b07af51649 | ||
|
|
735b8cd8b0 | ||
|
|
240058cd32 | ||
|
|
433c2f37bd | ||
|
|
548e39eb82 | ||
|
|
84789c5f26 | ||
|
|
24ae8b2015 | ||
|
|
d6223e45a4 | ||
|
|
0a985fe891 | ||
|
|
33f63f3463 | ||
|
|
770c265567 | ||
|
|
89f1daa226 | ||
|
|
914c825725 | ||
|
|
d8b774ccfe | ||
|
|
af5de8bdb6 | ||
|
|
397a7f56d4 | ||
|
|
15d9f82081 | ||
|
|
ec653812b9 | ||
|
|
8159ebe671 | ||
|
|
ccd22742f7 | ||
|
|
6b078392ee | ||
|
|
741bd325d6 | ||
|
|
01b28f76e5 | ||
|
|
1e125b2fdd | ||
|
|
9848ef22ec | ||
|
|
7466c75534 | ||
|
|
3373db8fc7 | ||
|
|
18d7ec8a01 | ||
|
|
c6ed7720dc | ||
|
|
724b35d7b5 | ||
|
|
1dd1a80f91 | ||
|
|
963cdceb83 | ||
|
|
90bb307486 | ||
|
|
c67b79785e | ||
|
|
c3f91a89b9 | ||
|
|
9e4518d5ca | ||
|
|
d3e801780e | ||
|
|
783c314a46 | ||
|
|
eda303bb0f | ||
|
|
ee1658e826 | ||
|
|
3f21cb5435 | ||
|
|
9a911fc146 | ||
|
|
fcf3de17a5 | ||
|
|
2729326131 | ||
|
|
f3dcf6ece0 | ||
|
|
3acd5fb986 | ||
|
|
c8a97db52e | ||
|
|
8e8560417a | ||
|
|
101c2602ae | ||
|
|
1d8839ae74 | ||
|
|
3eb6235bf1 |
@@ -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://github.com/user-attachments/assets/903482d4-3e87-4134-9af1-f2588fa90659" height="60" width="288" >](https://monica.im/?utm=nxcrp)
|
||||
|
||||
</div>
|
||||
|
||||
## Enterprise Edition
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { useEffect, useState, useRef, useMemo } from "react";
|
||||
import {
|
||||
useEffect,
|
||||
useState,
|
||||
useRef,
|
||||
useMemo,
|
||||
forwardRef,
|
||||
useImperativeHandle,
|
||||
} from "react";
|
||||
import { useParams } from "react-router";
|
||||
import { useWindowSize } from "@/app/utils";
|
||||
import { IconButton } from "./button";
|
||||
@@ -8,6 +15,7 @@ import CopyIcon from "../icons/copy.svg";
|
||||
import DownloadIcon from "../icons/download.svg";
|
||||
import GithubIcon from "../icons/github.svg";
|
||||
import LoadingButtonIcon from "../icons/loading.svg";
|
||||
import ReloadButtonIcon from "../icons/reload.svg";
|
||||
import Locale from "../locales";
|
||||
import { Modal, showToast } from "./ui-lib";
|
||||
import { copyToClipboard, downloadAs } from "../utils";
|
||||
@@ -15,73 +23,89 @@ import { Path, ApiPath, REPO_URL } from "@/app/constant";
|
||||
import { Loading } from "./home";
|
||||
import styles from "./artifacts.module.scss";
|
||||
|
||||
export function HTMLPreview(props: {
|
||||
type HTMLPreviewProps = {
|
||||
code: string;
|
||||
autoHeight?: boolean;
|
||||
height?: number | string;
|
||||
onLoad?: (title?: string) => void;
|
||||
}) {
|
||||
const ref = useRef<HTMLIFrameElement>(null);
|
||||
const frameId = useRef<string>(nanoid());
|
||||
const [iframeHeight, setIframeHeight] = useState(600);
|
||||
const [title, setTitle] = useState("");
|
||||
/*
|
||||
* https://stackoverflow.com/questions/19739001/what-is-the-difference-between-srcdoc-and-src-datatext-html-in-an
|
||||
* 1. using srcdoc
|
||||
* 2. using src with dataurl:
|
||||
* easy to share
|
||||
* length limit (Data URIs cannot be larger than 32,768 characters.)
|
||||
*/
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const handleMessage = (e: any) => {
|
||||
const { id, height, title } = e.data;
|
||||
setTitle(title);
|
||||
if (id == frameId.current) {
|
||||
setIframeHeight(height);
|
||||
export type HTMLPreviewHander = {
|
||||
reload: () => void;
|
||||
};
|
||||
|
||||
export const HTMLPreview = forwardRef<HTMLPreviewHander, HTMLPreviewProps>(
|
||||
function HTMLPreview(props, ref) {
|
||||
const iframeRef = useRef<HTMLIFrameElement>(null);
|
||||
const [frameId, setFrameId] = useState<string>(nanoid());
|
||||
const [iframeHeight, setIframeHeight] = useState(600);
|
||||
const [title, setTitle] = useState("");
|
||||
/*
|
||||
* https://stackoverflow.com/questions/19739001/what-is-the-difference-between-srcdoc-and-src-datatext-html-in-an
|
||||
* 1. using srcdoc
|
||||
* 2. using src with dataurl:
|
||||
* easy to share
|
||||
* length limit (Data URIs cannot be larger than 32,768 characters.)
|
||||
*/
|
||||
|
||||
useEffect(() => {
|
||||
const handleMessage = (e: any) => {
|
||||
const { id, height, title } = e.data;
|
||||
setTitle(title);
|
||||
if (id == frameId) {
|
||||
setIframeHeight(height);
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", handleMessage);
|
||||
return () => {
|
||||
window.removeEventListener("message", handleMessage);
|
||||
};
|
||||
}, [frameId]);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
reload: () => {
|
||||
setFrameId(nanoid());
|
||||
},
|
||||
}));
|
||||
|
||||
const height = useMemo(() => {
|
||||
if (!props.autoHeight) return props.height || 600;
|
||||
if (typeof props.height === "string") {
|
||||
return props.height;
|
||||
}
|
||||
const parentHeight = props.height || 600;
|
||||
return iframeHeight + 40 > parentHeight
|
||||
? parentHeight
|
||||
: iframeHeight + 40;
|
||||
}, [props.autoHeight, props.height, iframeHeight]);
|
||||
|
||||
const srcDoc = useMemo(() => {
|
||||
const script = `<script>new ResizeObserver((entries) => parent.postMessage({id: '${frameId}', height: entries[0].target.clientHeight}, '*')).observe(document.body)</script>`;
|
||||
if (props.code.includes("<!DOCTYPE html>")) {
|
||||
props.code.replace("<!DOCTYPE html>", "<!DOCTYPE html>" + script);
|
||||
}
|
||||
return script + props.code;
|
||||
}, [props.code, frameId]);
|
||||
|
||||
const handleOnLoad = () => {
|
||||
if (props?.onLoad) {
|
||||
props.onLoad(title);
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", handleMessage);
|
||||
return () => {
|
||||
window.removeEventListener("message", handleMessage);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const height = useMemo(() => {
|
||||
if (!props.autoHeight) return props.height || 600;
|
||||
if (typeof props.height === "string") {
|
||||
return props.height;
|
||||
}
|
||||
const parentHeight = props.height || 600;
|
||||
return iframeHeight + 40 > parentHeight ? parentHeight : iframeHeight + 40;
|
||||
}, [props.autoHeight, props.height, iframeHeight]);
|
||||
|
||||
const srcDoc = useMemo(() => {
|
||||
const script = `<script>new ResizeObserver((entries) => parent.postMessage({id: '${frameId.current}', height: entries[0].target.clientHeight}, '*')).observe(document.body)</script>`;
|
||||
if (props.code.includes("</head>")) {
|
||||
props.code.replace("</head>", "</head>" + script);
|
||||
}
|
||||
return props.code + script;
|
||||
}, [props.code]);
|
||||
|
||||
const handleOnLoad = () => {
|
||||
if (props?.onLoad) {
|
||||
props.onLoad(title);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<iframe
|
||||
className={styles["artifacts-iframe"]}
|
||||
id={frameId.current}
|
||||
ref={ref}
|
||||
sandbox="allow-forms allow-modals allow-scripts"
|
||||
style={{ height }}
|
||||
srcDoc={srcDoc}
|
||||
onLoad={handleOnLoad}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<iframe
|
||||
className={styles["artifacts-iframe"]}
|
||||
key={frameId}
|
||||
ref={iframeRef}
|
||||
sandbox="allow-forms allow-modals allow-scripts"
|
||||
style={{ height }}
|
||||
srcDoc={srcDoc}
|
||||
onLoad={handleOnLoad}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
export function ArtifactsShareButton({
|
||||
getCode,
|
||||
@@ -184,6 +208,7 @@ export function Artifacts() {
|
||||
const [code, setCode] = useState("");
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [fileName, setFileName] = useState("");
|
||||
const previewRef = useRef<HTMLPreviewHander>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
@@ -208,6 +233,13 @@ export function Artifacts() {
|
||||
<a href={REPO_URL} target="_blank" rel="noopener noreferrer">
|
||||
<IconButton bordered icon={<GithubIcon />} shadow />
|
||||
</a>
|
||||
<IconButton
|
||||
bordered
|
||||
style={{ marginLeft: 20 }}
|
||||
icon={<ReloadButtonIcon />}
|
||||
shadow
|
||||
onClick={() => previewRef.current?.reload()}
|
||||
/>
|
||||
<div className={styles["artifacts-title"]}>NextChat Artifacts</div>
|
||||
<ArtifactsShareButton
|
||||
id={id}
|
||||
@@ -220,6 +252,7 @@ export function Artifacts() {
|
||||
{code && (
|
||||
<HTMLPreview
|
||||
code={code}
|
||||
ref={previewRef}
|
||||
autoHeight={false}
|
||||
height={"100%"}
|
||||
onLoad={(title) => {
|
||||
|
||||
@@ -1587,7 +1587,7 @@ function _Chat() {
|
||||
message.content.length === 0 &&
|
||||
!isUser
|
||||
}
|
||||
onContextMenu={(e) => onRightClick(e, message)}
|
||||
// onContextMenu={(e) => onRightClick(e, message)} // hard to use
|
||||
onDoubleClickCapture={() => {
|
||||
if (!isMobileScreen) return;
|
||||
setUserInput(getMessageTextContent(message));
|
||||
|
||||
@@ -59,6 +59,13 @@ const MaskPage = dynamic(async () => (await import("./mask")).MaskPage, {
|
||||
loading: () => <Loading noLogo />,
|
||||
});
|
||||
|
||||
const SearchChat = dynamic(
|
||||
async () => (await import("./search-chat")).SearchChatPage,
|
||||
{
|
||||
loading: () => <Loading noLogo />,
|
||||
},
|
||||
);
|
||||
|
||||
const Sd = dynamic(async () => (await import("./sd")).Sd, {
|
||||
loading: () => <Loading noLogo />,
|
||||
});
|
||||
@@ -174,6 +181,7 @@ function Screen() {
|
||||
<Route path={Path.Home} element={<Chat />} />
|
||||
<Route path={Path.NewChat} element={<NewChat />} />
|
||||
<Route path={Path.Masks} element={<MaskPage />} />
|
||||
<Route path={Path.SearchChat} element={<SearchChat />} />
|
||||
<Route path={Path.Chat} element={<Chat />} />
|
||||
<Route path={Path.Settings} element={<Settings />} />
|
||||
</Routes>
|
||||
|
||||
@@ -8,14 +8,21 @@ import RehypeHighlight from "rehype-highlight";
|
||||
import { useRef, useState, RefObject, useEffect, useMemo } from "react";
|
||||
import { copyToClipboard, useWindowSize } from "../utils";
|
||||
import mermaid from "mermaid";
|
||||
|
||||
import Locale from "../locales";
|
||||
import LoadingIcon from "../icons/three-dots.svg";
|
||||
import ReloadButtonIcon from "../icons/reload.svg";
|
||||
import React from "react";
|
||||
import { useDebouncedCallback } from "use-debounce";
|
||||
import { showImageModal, FullScreen } from "./ui-lib";
|
||||
import { ArtifactsShareButton, HTMLPreview } from "./artifacts";
|
||||
import {
|
||||
ArtifactsShareButton,
|
||||
HTMLPreview,
|
||||
HTMLPreviewHander,
|
||||
} from "./artifacts";
|
||||
import { Plugin } from "../constant";
|
||||
import { useChatStore } from "../store";
|
||||
import { IconButton } from "./button";
|
||||
|
||||
export function Mermaid(props: { code: string }) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const [hasError, setHasError] = useState(false);
|
||||
@@ -64,7 +71,7 @@ export function Mermaid(props: { code: string }) {
|
||||
|
||||
export function PreCode(props: { children: any }) {
|
||||
const ref = useRef<HTMLPreElement>(null);
|
||||
const refText = ref.current?.innerText;
|
||||
const previewRef = useRef<HTMLPreviewHander>(null);
|
||||
const [mermaidCode, setMermaidCode] = useState("");
|
||||
const [htmlCode, setHtmlCode] = useState("");
|
||||
const { height } = useWindowSize();
|
||||
@@ -79,6 +86,7 @@ export function PreCode(props: { children: any }) {
|
||||
setMermaidCode((mermaidDom as HTMLElement).innerText);
|
||||
}
|
||||
const htmlDom = ref.current.querySelector("code.language-html");
|
||||
const refText = ref.current.querySelector("code")?.innerText;
|
||||
if (htmlDom) {
|
||||
setHtmlCode((htmlDom as HTMLElement).innerText);
|
||||
} else if (refText?.startsWith("<!DOCTYPE")) {
|
||||
@@ -86,11 +94,6 @@ export function PreCode(props: { children: any }) {
|
||||
}
|
||||
}, 600);
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(renderArtifacts, 1);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [refText]);
|
||||
|
||||
const enableArtifacts = useMemo(
|
||||
() => plugins?.includes(Plugin.Artifacts),
|
||||
[plugins],
|
||||
@@ -119,6 +122,7 @@ export function PreCode(props: { children: any }) {
|
||||
codeElement.style.whiteSpace = "pre-wrap";
|
||||
}
|
||||
});
|
||||
setTimeout(renderArtifacts, 1);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -145,7 +149,15 @@ export function PreCode(props: { children: any }) {
|
||||
style={{ position: "absolute", right: 20, top: 10 }}
|
||||
getCode={() => htmlCode}
|
||||
/>
|
||||
<IconButton
|
||||
style={{ position: "absolute", right: 120, top: 10 }}
|
||||
bordered
|
||||
icon={<ReloadButtonIcon />}
|
||||
shadow
|
||||
onClick={() => previewRef.current?.reload()}
|
||||
/>
|
||||
<HTMLPreview
|
||||
ref={previewRef}
|
||||
code={htmlCode}
|
||||
autoHeight={!document.fullscreenElement}
|
||||
height={!document.fullscreenElement ? 600 : height}
|
||||
@@ -182,16 +194,14 @@ function CustomCode(props: { children: any }) {
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
{showToggle && collapsed && (
|
||||
<div
|
||||
className={`show-hide-button ${
|
||||
collapsed ? "collapsed" : "expanded"
|
||||
}`}
|
||||
>
|
||||
<button onClick={toggleCollapsed}>查看全部</button>
|
||||
</div>
|
||||
)}
|
||||
</code>
|
||||
{showToggle && collapsed && (
|
||||
<div
|
||||
className={`show-hide-button ${collapsed ? "collapsed" : "expanded"}`}
|
||||
>
|
||||
<button onClick={toggleCollapsed}>{Locale.NewChat.More}</button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
167
app/components/search-chat.tsx
Normal file
167
app/components/search-chat.tsx
Normal file
@@ -0,0 +1,167 @@
|
||||
import { useState, useEffect, useRef, useCallback } from "react";
|
||||
import { ErrorBoundary } from "./error";
|
||||
import styles from "./mask.module.scss";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { IconButton } from "./button";
|
||||
import CloseIcon from "../icons/close.svg";
|
||||
import EyeIcon from "../icons/eye.svg";
|
||||
import Locale from "../locales";
|
||||
import { Path } from "../constant";
|
||||
|
||||
import { useChatStore } from "../store";
|
||||
|
||||
type Item = {
|
||||
id: number;
|
||||
name: string;
|
||||
content: string;
|
||||
};
|
||||
export function SearchChatPage() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const chatStore = useChatStore();
|
||||
|
||||
const sessions = chatStore.sessions;
|
||||
const selectSession = chatStore.selectSession;
|
||||
|
||||
const [searchResults, setSearchResults] = useState<Item[]>([]);
|
||||
|
||||
const previousValueRef = useRef<string>("");
|
||||
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||
const doSearch = useCallback((text: string) => {
|
||||
const lowerCaseText = text.toLowerCase();
|
||||
const results: Item[] = [];
|
||||
|
||||
sessions.forEach((session, index) => {
|
||||
const fullTextContents: string[] = [];
|
||||
|
||||
session.messages.forEach((message) => {
|
||||
const content = message.content as string;
|
||||
if (!content.toLowerCase || content === "") return;
|
||||
const lowerCaseContent = content.toLowerCase();
|
||||
|
||||
// full text search
|
||||
let pos = lowerCaseContent.indexOf(lowerCaseText);
|
||||
while (pos !== -1) {
|
||||
const start = Math.max(0, pos - 35);
|
||||
const end = Math.min(content.length, pos + lowerCaseText.length + 35);
|
||||
fullTextContents.push(content.substring(start, end));
|
||||
pos = lowerCaseContent.indexOf(
|
||||
lowerCaseText,
|
||||
pos + lowerCaseText.length,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (fullTextContents.length > 0) {
|
||||
results.push({
|
||||
id: index,
|
||||
name: session.topic,
|
||||
content: fullTextContents.join("... "), // concat content with...
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// sort by length of matching content
|
||||
results.sort((a, b) => b.content.length - a.content.length);
|
||||
|
||||
return results;
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
if (searchInputRef.current) {
|
||||
const currentValue = searchInputRef.current.value;
|
||||
if (currentValue !== previousValueRef.current) {
|
||||
if (currentValue.length > 0) {
|
||||
const result = doSearch(currentValue);
|
||||
setSearchResults(result);
|
||||
}
|
||||
previousValueRef.current = currentValue;
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
// Cleanup the interval on component unmount
|
||||
return () => clearInterval(intervalId);
|
||||
}, [doSearch]);
|
||||
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<div className={styles["mask-page"]}>
|
||||
{/* header */}
|
||||
<div className="window-header">
|
||||
<div className="window-header-title">
|
||||
<div className="window-header-main-title">
|
||||
{Locale.SearchChat.Page.Title}
|
||||
</div>
|
||||
<div className="window-header-submai-title">
|
||||
{Locale.SearchChat.Page.SubTitle(searchResults.length)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="window-actions">
|
||||
<div className="window-action-button">
|
||||
<IconButton
|
||||
icon={<CloseIcon />}
|
||||
bordered
|
||||
onClick={() => navigate(-1)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={styles["mask-page-body"]}>
|
||||
<div className={styles["mask-filter"]}>
|
||||
{/**搜索输入框 */}
|
||||
<input
|
||||
type="text"
|
||||
className={styles["search-bar"]}
|
||||
placeholder={Locale.SearchChat.Page.Search}
|
||||
autoFocus
|
||||
ref={searchInputRef}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
const searchText = e.currentTarget.value;
|
||||
if (searchText.length > 0) {
|
||||
const result = doSearch(searchText);
|
||||
setSearchResults(result);
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{searchResults.map((item) => (
|
||||
<div
|
||||
className={styles["mask-item"]}
|
||||
key={item.id}
|
||||
onClick={() => {
|
||||
navigate(Path.Chat);
|
||||
selectSession(item.id);
|
||||
}}
|
||||
style={{ cursor: "pointer" }}
|
||||
>
|
||||
{/** 搜索匹配的文本 */}
|
||||
<div className={styles["mask-header"]}>
|
||||
<div className={styles["mask-title"]}>
|
||||
<div className={styles["mask-name"]}>{item.name}</div>
|
||||
{item.content.slice(0, 70)}
|
||||
</div>
|
||||
</div>
|
||||
{/** 操作按钮 */}
|
||||
<div className={styles["mask-actions"]}>
|
||||
<IconButton
|
||||
icon={<EyeIcon />}
|
||||
text={Locale.SearchChat.Item.View}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import path from "path";
|
||||
|
||||
export const OWNER = "ChatGPTNextWeb";
|
||||
export const REPO = "ChatGPT-Next-Web";
|
||||
export const REPO_URL = `https://github.com/${OWNER}/${REPO}`;
|
||||
@@ -41,6 +43,7 @@ export enum Path {
|
||||
Sd = "/sd",
|
||||
SdNew = "/sd-new",
|
||||
Artifacts = "/artifacts",
|
||||
SearchChat = "/search-chat",
|
||||
}
|
||||
|
||||
export enum ApiPath {
|
||||
@@ -475,4 +478,7 @@ export const internalAllowedWebDavEndpoints = [
|
||||
];
|
||||
|
||||
export const DEFAULT_GA_ID = "G-89WN60ZK2E";
|
||||
export const PLUGINS = [{ name: "Stable Diffusion", path: Path.Sd }];
|
||||
export const PLUGINS = [
|
||||
{ name: "Stable Diffusion", path: Path.Sd },
|
||||
{ name: "Search Chat", path: Path.SearchChat },
|
||||
];
|
||||
|
||||
1
app/icons/zoom.svg
Normal file
1
app/icons/zoom.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1.2rem" height="1.2rem" viewBox="0 0 24 24"><g fill="none" stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></g></svg>
|
||||
|
After Width: | Height: | Size: 285 B |
@@ -459,6 +459,21 @@ const ar: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "أنت مساعد",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "بحث",
|
||||
Page: {
|
||||
Title: "البحث في سجلات الدردشة",
|
||||
Search: "أدخل كلمات البحث",
|
||||
NoResult: "لم يتم العثور على نتائج",
|
||||
NoData: "لا توجد بيانات",
|
||||
Loading: "جارٍ التحميل",
|
||||
|
||||
SubTitle: (count: number) => `تم العثور على ${count} نتائج`,
|
||||
},
|
||||
Item: {
|
||||
View: "عرض",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "القناع",
|
||||
Page: {
|
||||
|
||||
@@ -466,6 +466,21 @@ const bn: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "আপনি একজন সহকারী",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "অনুসন্ধান",
|
||||
Page: {
|
||||
Title: "চ্যাট রেকর্ড অনুসন্ধান করুন",
|
||||
Search: "অনুসন্ধান কীওয়ার্ড লিখুন",
|
||||
NoResult: "কোন ফলাফল পাওয়া যায়নি",
|
||||
NoData: "কোন তথ্য নেই",
|
||||
Loading: "লোড হচ্ছে",
|
||||
|
||||
SubTitle: (count: number) => `${count} টি ফলাফল পাওয়া গেছে`,
|
||||
},
|
||||
Item: {
|
||||
View: "দেখুন",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "মাস্ক",
|
||||
Page: {
|
||||
|
||||
@@ -519,6 +519,21 @@ const cn = {
|
||||
FineTuned: {
|
||||
Sysmessage: "你是一个助手",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "搜索",
|
||||
Page: {
|
||||
Title: "搜索聊天记录",
|
||||
Search: "输入搜索关键词",
|
||||
NoResult: "没有找到结果",
|
||||
NoData: "没有数据",
|
||||
Loading: "加载中",
|
||||
|
||||
SubTitle: (count: number) => `搜索到 ${count} 条结果`,
|
||||
},
|
||||
Item: {
|
||||
View: "查看",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "面具",
|
||||
Page: {
|
||||
|
||||
@@ -467,6 +467,21 @@ const cs: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Jste asistent",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Hledat",
|
||||
Page: {
|
||||
Title: "Hledat v historii chatu",
|
||||
Search: "Zadejte hledané klíčové slovo",
|
||||
NoResult: "Nebyly nalezeny žádné výsledky",
|
||||
NoData: "Žádná data",
|
||||
Loading: "Načítání",
|
||||
|
||||
SubTitle: (count: number) => `Nalezeno ${count} výsledků`,
|
||||
},
|
||||
Item: {
|
||||
View: "Zobrazit",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Maska",
|
||||
Page: {
|
||||
|
||||
@@ -482,6 +482,21 @@ const de: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Du bist ein Assistent",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Suche",
|
||||
Page: {
|
||||
Title: "Chatverlauf durchsuchen",
|
||||
Search: "Suchbegriff eingeben",
|
||||
NoResult: "Keine Ergebnisse gefunden",
|
||||
NoData: "Keine Daten",
|
||||
Loading: "Laden",
|
||||
|
||||
SubTitle: (count: number) => `${count} Ergebnisse gefunden`,
|
||||
},
|
||||
Item: {
|
||||
View: "Ansehen",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Masken",
|
||||
Page: {
|
||||
|
||||
@@ -527,6 +527,21 @@ const en: LocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "You are an assistant that",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Search",
|
||||
Page: {
|
||||
Title: "Search Chat History",
|
||||
Search: "Enter search query to search chat history",
|
||||
NoResult: "No results found",
|
||||
NoData: "No data",
|
||||
Loading: "Loading...",
|
||||
|
||||
SubTitle: (count: number) => `Found ${count} results`,
|
||||
},
|
||||
Item: {
|
||||
View: "View",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Mask",
|
||||
Page: {
|
||||
|
||||
@@ -480,6 +480,21 @@ const es: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Eres un asistente",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Buscar",
|
||||
Page: {
|
||||
Title: "Buscar en el historial de chat",
|
||||
Search: "Ingrese la palabra clave de búsqueda",
|
||||
NoResult: "No se encontraron resultados",
|
||||
NoData: "Sin datos",
|
||||
Loading: "Cargando",
|
||||
|
||||
SubTitle: (count: number) => `Se encontraron ${count} resultados`,
|
||||
},
|
||||
Item: {
|
||||
View: "Ver",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Máscara",
|
||||
Page: {
|
||||
|
||||
@@ -480,6 +480,21 @@ const fr: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Vous êtes un assistant",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Recherche",
|
||||
Page: {
|
||||
Title: "Rechercher dans l'historique des discussions",
|
||||
Search: "Entrez le mot-clé de recherche",
|
||||
NoResult: "Aucun résultat trouvé",
|
||||
NoData: "Aucune donnée",
|
||||
Loading: "Chargement",
|
||||
|
||||
SubTitle: (count: number) => `${count} résultats trouvés`,
|
||||
},
|
||||
Item: {
|
||||
View: "Voir",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Masque",
|
||||
Page: {
|
||||
|
||||
@@ -470,6 +470,21 @@ const id: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Anda adalah seorang asisten",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Cari",
|
||||
Page: {
|
||||
Title: "Cari riwayat obrolan",
|
||||
Search: "Masukkan kata kunci pencarian",
|
||||
NoResult: "Tidak ada hasil ditemukan",
|
||||
NoData: "Tidak ada data",
|
||||
Loading: "Memuat",
|
||||
|
||||
SubTitle: (count: number) => `Ditemukan ${count} hasil`,
|
||||
},
|
||||
Item: {
|
||||
View: "Lihat",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Masker",
|
||||
Page: {
|
||||
|
||||
@@ -481,6 +481,21 @@ const it: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Sei un assistente",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Cerca",
|
||||
Page: {
|
||||
Title: "Cerca nei messaggi",
|
||||
Search: "Inserisci parole chiave per la ricerca",
|
||||
NoResult: "Nessun risultato trovato",
|
||||
NoData: "Nessun dato",
|
||||
Loading: "Caricamento in corso",
|
||||
|
||||
SubTitle: (count: number) => `Trovati ${count} risultati`,
|
||||
},
|
||||
Item: {
|
||||
View: "Visualizza",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Maschera",
|
||||
Page: {
|
||||
|
||||
@@ -460,9 +460,27 @@ const jp: PartialLocaleType = {
|
||||
Plugin: {
|
||||
Name: "プラグイン",
|
||||
},
|
||||
Discovery: {
|
||||
Name: "発見",
|
||||
},
|
||||
FineTuned: {
|
||||
Sysmessage: "あなたはアシスタントです",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "検索",
|
||||
Page: {
|
||||
Title: "チャット履歴を検索",
|
||||
Search: "検索キーワードを入力",
|
||||
NoResult: "結果が見つかりませんでした",
|
||||
NoData: "データがありません",
|
||||
Loading: "読み込み中",
|
||||
|
||||
SubTitle: (count: number) => `${count} 件の結果が見つかりました`,
|
||||
},
|
||||
Item: {
|
||||
View: "表示",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "マスク",
|
||||
Page: {
|
||||
|
||||
@@ -458,6 +458,21 @@ const ko: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "당신은 보조자입니다.",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "검색",
|
||||
Page: {
|
||||
Title: "채팅 기록 검색",
|
||||
Search: "검색어 입력",
|
||||
NoResult: "결과를 찾을 수 없습니다",
|
||||
NoData: "데이터가 없습니다",
|
||||
Loading: "로딩 중",
|
||||
|
||||
SubTitle: (count: number) => `${count}개의 결과를 찾았습니다`,
|
||||
},
|
||||
Item: {
|
||||
View: "보기",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "마스크",
|
||||
Page: {
|
||||
|
||||
@@ -474,6 +474,21 @@ const no: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Du er en assistent",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Søk",
|
||||
Page: {
|
||||
Title: "Søk i chatthistorikk",
|
||||
Search: "Skriv inn søkeord",
|
||||
NoResult: "Ingen resultater funnet",
|
||||
NoData: "Ingen data",
|
||||
Loading: "Laster inn",
|
||||
|
||||
SubTitle: (count: number) => `Fant ${count} resultater`,
|
||||
},
|
||||
Item: {
|
||||
View: "Vis",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Maske",
|
||||
Page: {
|
||||
|
||||
@@ -405,6 +405,21 @@ const pt: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Você é um assistente que",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Pesquisar",
|
||||
Page: {
|
||||
Title: "Pesquisar histórico de chat",
|
||||
Search: "Digite palavras-chave para pesquisa",
|
||||
NoResult: "Nenhum resultado encontrado",
|
||||
NoData: "Sem dados",
|
||||
Loading: "Carregando",
|
||||
|
||||
SubTitle: (count: number) => `Encontrado ${count} resultados`,
|
||||
},
|
||||
Item: {
|
||||
View: "Ver",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Máscara",
|
||||
Page: {
|
||||
|
||||
@@ -471,6 +471,21 @@ const ru: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Вы - помощник",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Поиск",
|
||||
Page: {
|
||||
Title: "Поиск в истории чатов",
|
||||
Search: "Введите ключевые слова для поиска",
|
||||
NoResult: "Результатов не найдено",
|
||||
NoData: "Нет данных",
|
||||
Loading: "Загрузка",
|
||||
|
||||
SubTitle: (count: number) => `Найдено ${count} результатов`,
|
||||
},
|
||||
Item: {
|
||||
View: "Просмотр",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Маска",
|
||||
Page: {
|
||||
|
||||
@@ -423,6 +423,21 @@ const sk: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Ste asistent, ktorý",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Hľadať",
|
||||
Page: {
|
||||
Title: "Hľadať v histórii chatu",
|
||||
Search: "Zadajte kľúčové slová na vyhľadávanie",
|
||||
NoResult: "Nenašli sa žiadne výsledky",
|
||||
NoData: "Žiadne údaje",
|
||||
Loading: "Načítava sa",
|
||||
|
||||
SubTitle: (count: number) => `Nájdených ${count} výsledkov`,
|
||||
},
|
||||
Item: {
|
||||
View: "Zobraziť",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Maska",
|
||||
Page: {
|
||||
|
||||
@@ -470,6 +470,21 @@ const tr: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Sen bir asistansın",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Ara",
|
||||
Page: {
|
||||
Title: "Sohbet geçmişini ara",
|
||||
Search: "Arama anahtar kelimelerini girin",
|
||||
NoResult: "Sonuç bulunamadı",
|
||||
NoData: "Veri yok",
|
||||
Loading: "Yükleniyor",
|
||||
|
||||
SubTitle: (count: number) => `${count} sonuç bulundu`,
|
||||
},
|
||||
Item: {
|
||||
View: "Görüntüle",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Maske",
|
||||
Page: {
|
||||
|
||||
@@ -452,6 +452,21 @@ const tw = {
|
||||
},
|
||||
},
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "搜索",
|
||||
Page: {
|
||||
Title: "搜索聊天記錄",
|
||||
Search: "輸入搜索關鍵詞",
|
||||
NoResult: "沒有找到結果",
|
||||
NoData: "沒有數據",
|
||||
Loading: "加載中",
|
||||
|
||||
SubTitle: (count: number) => `找到 ${count} 條結果`,
|
||||
},
|
||||
Item: {
|
||||
View: "查看",
|
||||
},
|
||||
},
|
||||
NewChat: {
|
||||
Return: "返回",
|
||||
Skip: "跳過",
|
||||
|
||||
@@ -466,6 +466,21 @@ const vi: PartialLocaleType = {
|
||||
FineTuned: {
|
||||
Sysmessage: "Bạn là một trợ lý",
|
||||
},
|
||||
SearchChat: {
|
||||
Name: "Tìm kiếm",
|
||||
Page: {
|
||||
Title: "Tìm kiếm lịch sử trò chuyện",
|
||||
Search: "Nhập từ khóa tìm kiếm",
|
||||
NoResult: "Không tìm thấy kết quả",
|
||||
NoData: "Không có dữ liệu",
|
||||
Loading: "Đang tải",
|
||||
|
||||
SubTitle: (count: number) => `Tìm thấy ${count} kết quả`,
|
||||
},
|
||||
Item: {
|
||||
View: "Xem",
|
||||
},
|
||||
},
|
||||
Mask: {
|
||||
Name: "Mặt nạ",
|
||||
Page: {
|
||||
|
||||
@@ -183,7 +183,7 @@ export const useAccessStore = createPersistStore(
|
||||
this.isValidBaidu() ||
|
||||
this.isValidByteDance() ||
|
||||
this.isValidAlibaba() ||
|
||||
this.isValidTencent ||
|
||||
this.isValidTencent() ||
|
||||
this.isValidMoonshot() ||
|
||||
this.isValidIflytek() ||
|
||||
!this.enabledAccessControl() ||
|
||||
|
||||
@@ -27,6 +27,7 @@ import { createPersistStore } from "../utils/store";
|
||||
import { collectModelsWithDefaultModel } from "../utils/model";
|
||||
import { useAccessStore } from "./access";
|
||||
import { isDalle3 } from "../utils";
|
||||
import { indexedDBStorage } from "@/app/utils/indexedDB-storage";
|
||||
|
||||
export type ChatMessage = RequestMessage & {
|
||||
date: string;
|
||||
@@ -665,7 +666,8 @@ export const useChatStore = createPersistStore(
|
||||
set(() => ({ sessions }));
|
||||
},
|
||||
|
||||
clearAllData() {
|
||||
async clearAllData() {
|
||||
await indexedDBStorage.clear();
|
||||
localStorage.clear();
|
||||
location.reload();
|
||||
},
|
||||
|
||||
@@ -304,7 +304,7 @@ pre {
|
||||
}
|
||||
}
|
||||
|
||||
code{
|
||||
pre {
|
||||
.show-hide-button {
|
||||
border-radius: 10px;
|
||||
position: absolute;
|
||||
@@ -314,7 +314,9 @@ code{
|
||||
height: fit-content;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
pointer-events: none;
|
||||
button{
|
||||
pointer-events: auto;
|
||||
margin-top: 3em;
|
||||
margin-bottom: 4em;
|
||||
padding: 5px 16px;
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useAllModels() {
|
||||
const models = useMemo(() => {
|
||||
return collectModelsWithDefaultModel(
|
||||
configStore.models,
|
||||
[configStore.customModels, accessStore.customModels].join(","),
|
||||
[accessStore.customModels, configStore.customModels].join(","),
|
||||
accessStore.defaultModel,
|
||||
);
|
||||
}, [
|
||||
|
||||
44
app/utils/indexedDB-storage.ts
Normal file
44
app/utils/indexedDB-storage.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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 {
|
||||
const value = (await get(name)) || localStorage.getItem(name);
|
||||
return value;
|
||||
} catch (error) {
|
||||
return localStorage.getItem(name);
|
||||
}
|
||||
}
|
||||
|
||||
public async setItem(name: string, value: string): Promise<void> {
|
||||
try {
|
||||
const _value = JSON.parse(value);
|
||||
if (!_value?.state?._hasHydrated) {
|
||||
console.warn("skip setItem", name);
|
||||
return;
|
||||
}
|
||||
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 { combine, persist } from "zustand/middleware";
|
||||
import { combine, persist, createJSONStorage } from "zustand/middleware";
|
||||
import { Updater } from "../typing";
|
||||
import { deepClone } from "./clone";
|
||||
import { indexedDBStorage } from "@/app/utils/indexedDB-storage";
|
||||
|
||||
type SecondParam<T> = T extends (
|
||||
_f: infer _F,
|
||||
@@ -13,9 +14,11 @@ type SecondParam<T> = T extends (
|
||||
|
||||
type MakeUpdater<T> = {
|
||||
lastUpdateTime: number;
|
||||
_hasHydrated: boolean;
|
||||
|
||||
markUpdate: () => void;
|
||||
update: Updater<T>;
|
||||
setHasHydrated: (state: boolean) => void;
|
||||
};
|
||||
|
||||
type SetStoreState<T> = (
|
||||
@@ -31,12 +34,20 @@ export function createPersistStore<T extends object, M>(
|
||||
) => M,
|
||||
persistOptions: SecondParam<typeof persist<T & M & MakeUpdater<T>>>,
|
||||
) {
|
||||
persistOptions.storage = createJSONStorage(() => indexedDBStorage);
|
||||
const oldOonRehydrateStorage = persistOptions?.onRehydrateStorage;
|
||||
persistOptions.onRehydrateStorage = (state) => {
|
||||
oldOonRehydrateStorage?.(state);
|
||||
return () => state.setHasHydrated(true);
|
||||
};
|
||||
|
||||
return create(
|
||||
persist(
|
||||
combine(
|
||||
{
|
||||
...state,
|
||||
lastUpdateTime: 0,
|
||||
_hasHydrated: false,
|
||||
},
|
||||
(set, get) => {
|
||||
return {
|
||||
@@ -55,6 +66,9 @@ export function createPersistStore<T extends object, M>(
|
||||
lastUpdateTime: Date.now(),
|
||||
});
|
||||
},
|
||||
setHasHydrated: (state: boolean) => {
|
||||
set({ _hasHydrated: state } as Partial<T & M & MakeUpdater<T>>);
|
||||
},
|
||||
} as M & MakeUpdater<T>;
|
||||
},
|
||||
),
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
"fuse.js": "^7.0.0",
|
||||
"heic2any": "^0.0.4",
|
||||
"html-to-image": "^1.11.11",
|
||||
"idb-keyval": "^6.2.1",
|
||||
"lodash-es": "^4.17.21",
|
||||
"mermaid": "^10.6.1",
|
||||
"nanoid": "^5.0.3",
|
||||
|
||||
@@ -3926,6 +3926,11 @@ iconv-lite@0.6:
|
||||
dependencies:
|
||||
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:
|
||||
version "5.2.4"
|
||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
|
||||
|
||||
Reference in New Issue
Block a user