mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-09 19:46:37 +08:00
用户输入框内容会随着Session切换而切换
This commit is contained in:
parent
ef269acc20
commit
c67af258d3
@ -87,21 +87,14 @@ export function ChatItem(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ChatList() {
|
export function ChatList() {
|
||||||
const [
|
const [sidebarCollapse, sessions, selectedIndex, selectSession, moveSession] =
|
||||||
sidebarCollapse,
|
useChatStore((state) => [
|
||||||
sessions,
|
state.sidebarCollapse,
|
||||||
selectedIndex,
|
state.sessions,
|
||||||
selectSession,
|
state.currentSessionIndex,
|
||||||
removeSession,
|
state.selectSession,
|
||||||
moveSession,
|
state.moveSession,
|
||||||
] = useChatStore((state) => [
|
]);
|
||||||
state.sidebarCollapse,
|
|
||||||
state.sessions,
|
|
||||||
state.currentSessionIndex,
|
|
||||||
state.selectSession,
|
|
||||||
state.removeSession,
|
|
||||||
state.moveSession,
|
|
||||||
]);
|
|
||||||
const chatStore = useChatStore();
|
const chatStore = useChatStore();
|
||||||
const onDragEnd: OnDragEndResponder = (result: any) => {
|
const onDragEnd: OnDragEndResponder = (result: any) => {
|
||||||
const { destination, source } = result;
|
const { destination, source } = result;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useDebounce, useDebouncedCallback } from "use-debounce";
|
import { useDebouncedCallback } from "use-debounce";
|
||||||
import { memo, useState, useRef, useEffect, useLayoutEffect } from "react";
|
import { memo, useState, useRef, useEffect, useLayoutEffect } from "react";
|
||||||
|
|
||||||
import SendWhiteIcon from "../icons/send-white.svg";
|
import SendWhiteIcon from "../icons/send-white.svg";
|
||||||
@ -37,7 +37,6 @@ import {
|
|||||||
isMobileScreen,
|
isMobileScreen,
|
||||||
selectOrCopy,
|
selectOrCopy,
|
||||||
autoGrowTextArea,
|
autoGrowTextArea,
|
||||||
getCSSVar,
|
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
|
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
@ -414,7 +413,7 @@ export function Chat() {
|
|||||||
const fontSize = useChatStore((state) => state.config.fontSize);
|
const fontSize = useChatStore((state) => state.config.fontSize);
|
||||||
|
|
||||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||||
const [userInput, setUserInput] = useState("");
|
const [userInput, setUserInput] = useState(session.userInput);
|
||||||
const [beforeInput, setBeforeInput] = useState("");
|
const [beforeInput, setBeforeInput] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const { submitKey, shouldSubmit } = useSubmitHandler();
|
const { submitKey, shouldSubmit } = useSubmitHandler();
|
||||||
@ -471,8 +470,23 @@ export function Chat() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const updateUserInput = (text: string) => {
|
||||||
|
session.userInput = text;
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setUserInput(session.userInput);
|
||||||
|
}, [session]);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// updateUserInput(userInput);
|
||||||
|
// }, [userInput]);
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
useEffect(measure, [userInput]);
|
useEffect(() => {
|
||||||
|
measure;
|
||||||
|
updateUserInput(userInput);
|
||||||
|
}, [userInput]);
|
||||||
|
|
||||||
// only search prompts when user input is short
|
// only search prompts when user input is short
|
||||||
const SEARCH_TEXT_LIMIT = 30;
|
const SEARCH_TEXT_LIMIT = 30;
|
||||||
@ -586,7 +600,7 @@ export function Chat() {
|
|||||||
: [],
|
: [],
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
userInput.length > 0 && config.sendPreviewBubble
|
userInput && userInput.length > 0 && config.sendPreviewBubble
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
...createMessage({
|
...createMessage({
|
||||||
|
@ -174,6 +174,7 @@ export interface ChatSession {
|
|||||||
stat: ChatStat;
|
stat: ChatStat;
|
||||||
lastUpdate: string;
|
lastUpdate: string;
|
||||||
lastSummarizeIndex: number;
|
lastSummarizeIndex: number;
|
||||||
|
userInput: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_TOPIC = Locale.Store.DefaultTopic;
|
const DEFAULT_TOPIC = Locale.Store.DefaultTopic;
|
||||||
@ -199,6 +200,7 @@ function createEmptySession(): ChatSession {
|
|||||||
},
|
},
|
||||||
lastUpdate: createDate,
|
lastUpdate: createDate,
|
||||||
lastSummarizeIndex: 0,
|
lastSummarizeIndex: 0,
|
||||||
|
userInput: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user