From 5fa61d71463658e7d4659f40ac15ec1263f054e6 Mon Sep 17 00:00:00 2001 From: xiaozhu <2395895331@qq.com> Date: Thu, 6 Aug 2026 17:21:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E7=BC=96=E8=BE=91=E6=B2=A1=E5=8F=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/app/features/platform/ModelPlatformApp.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/frontend/app/features/platform/ModelPlatformApp.tsx b/frontend/app/features/platform/ModelPlatformApp.tsx index 8aa48f0..1505377 100644 --- a/frontend/app/features/platform/ModelPlatformApp.tsx +++ b/frontend/app/features/platform/ModelPlatformApp.tsx @@ -420,6 +420,7 @@ function AuthenticatedModelPlatformApp() { // 选择脚本 const selectScript = (scriptId: string | null) => { setSelectedId(scriptId); + selectedIdRef.current = scriptId; }; // 打开标签 @@ -440,23 +441,18 @@ function AuthenticatedModelPlatformApp() { // 关闭标签 const closeTab = async (scriptId: string, event?: ReactMouseEvent) => { - console.log('[closeTab] 开始关闭:', scriptId, '当前 selectedId:', selectedId); event?.stopPropagation(); if (editSessionRef.current?.script_id === scriptId) { - console.log('[closeTab] 需要结束编辑'); await endEditing(false, false); } // 从缓存中删除 sessionCacheRef.current.delete(scriptId); setOpenTabIds((current) => { - console.log('[closeTab] 当前标签栏:', current); const index = current.indexOf(scriptId); if (index === -1) return current; const newTabs = current.filter((id) => id !== scriptId); - console.log('[closeTab] 关闭后的标签栏:', newTabs); if (selectedId === scriptId) { const nextId = newTabs[index] ?? newTabs[index - 1] ?? null; - console.log('[closeTab] 选中下一个:', nextId); setSelectedId(nextId); selectedIdRef.current = nextId; } @@ -485,6 +481,7 @@ function AuthenticatedModelPlatformApp() { // 打开脚本编辑器 const openScriptEditor = async (script: ScriptItem, showToast = true) => { + if (!script) return; if (editorOpeningRef.current) return; editorOpeningRef.current = true; const requestId = editorOpenRequestRef.current + 1; @@ -760,10 +757,11 @@ function AuthenticatedModelPlatformApp() { for (const file of files) { lastCreated = await api.uploadScript(file, uploadParentPath); } - await load(true); + // 和新建文件逻辑一致:直接更新 scripts,不调用 load() + setScripts((items) => [lastCreated!, ...items]); + // 只打开最后一个文件 if (lastCreated) { openTab(lastCreated.script_id); - selectScript(lastCreated.script_id); } setToast({ tone: "success",