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",