更新token的计算方式,优化请求逻辑

This commit is contained in:
sijinhui 2024-05-08 22:52:15 +08:00
parent e214302817
commit 2c488675c6

View File

@ -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);