From 2c488675c649c1ffea7d943f0ec3f770efdfb505 Mon Sep 17 00:00:00 2001 From: sijinhui Date: Wed, 8 May 2024 22:52:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0token=E7=9A=84=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=96=B9=E5=BC=8F,=E4=BC=98=E5=8C=96=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/chat.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 36164a0ab..6859e0e13 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -1268,8 +1268,10 @@ function _Chat() { setAttachImages(images); } + // 加载状态结束,获取token + const [loadingChange, setLoadingChange] = useState(false); useEffect(() => { - if (!isLoading) { + if (!isLoading && loadingChange) { try { fetch("/api/logs/get_current_token", { method: "GET", @@ -1284,10 +1286,11 @@ function _Chat() { ); }); } catch {} - - console.log("加载消息完成。获取token"); } - }, [isLoading]); + return () => { + setLoadingChange(isLoading); + }; + }, [isLoading, loadingChange]); // const [ voiceInputText, setVoiceInputText ] = useState(""); // const [ voiceInputLoading, setVoiceInputLoading ] = useState(false);