From afdfad067cb63b9405d5814d0ed6671840d7948a Mon Sep 17 00:00:00 2001 From: song_xiao_lin <63901989+song-xiao-lin@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:56:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E8=A2=AB=E5=85=A8=E9=83=A8=E6=94=B9=E4=B8=BA=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=A8=A1=E5=9E=8B=20(#1717)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/src/components/yakChat/chatCS.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/renderer/src/main/src/components/yakChat/chatCS.tsx b/app/renderer/src/main/src/components/yakChat/chatCS.tsx index bda7feb24b..6c35bebbb2 100644 --- a/app/renderer/src/main/src/components/yakChat/chatCS.tsx +++ b/app/renderer/src/main/src/components/yakChat/chatCS.tsx @@ -2955,8 +2955,8 @@ export const PluginAIComponent: React.FC = (props) => { // 更新单独展示项 setPluginAIItem((lastItem) => lastItem.map((item, index) => { - item.info.extra = extra || {} if (lastItem.length === index + 1) { + item.info.extra = extra || {} item.info.content = content item.time = formatDate(+new Date()) return item @@ -2967,8 +2967,8 @@ export const PluginAIComponent: React.FC = (props) => { // 更新历史展示 setPluginAIList( newPluginAIList.map((item, index) => { - item.info.extra = extra || {} if (newPluginAIList.length === index + 1) { + item.info.extra = extra || {} item.info.content = content item.time = formatDate(+new Date()) return item @@ -2983,14 +2983,9 @@ export const PluginAIComponent: React.FC = (props) => { const updateExtraInfo = useMemoizedFn((extra) => { setPluginAIItem((lastItem) => lastItem.map((item) => { - item.info.extra = extra || {} - return item - }) - ) - const newPluginAIList: PluginAiItem[] = JSON.parse(JSON.stringify(pluginAIList)) - setPluginAIList( - newPluginAIList.map((item) => { - item.info.extra = extra || {} + if (!item.info.extra || JSON.stringify(item.info.extra) === "{}") { + item.info.extra = extra || {} + } return item }) ) @@ -3061,7 +3056,7 @@ export const PluginAIComponent: React.FC = (props) => { // 执行 const onStartExecute = useMemoizedFn((data: CodecParamsProps) => { - const {text, scriptName, isAiPlugin,code} = data + const {text, scriptName, isAiPlugin, code} = data const executeParams = { Input: text || "", PluginName: scriptName,