From 1ef9961307d30b7bdf18302d99837c51b368be13 Mon Sep 17 00:00:00 2001 From: xiaozhu <2395895331@qq.com> Date: Wed, 5 Aug 2026 16:25:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=88=87=E6=8D=A2=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E7=9B=AE=E5=BD=95=E6=9C=AA=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/platform/ModelPlatformApp.tsx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/frontend/app/features/platform/ModelPlatformApp.tsx b/frontend/app/features/platform/ModelPlatformApp.tsx index 8bf9fc5..9474406 100644 --- a/frontend/app/features/platform/ModelPlatformApp.tsx +++ b/frontend/app/features/platform/ModelPlatformApp.tsx @@ -184,6 +184,15 @@ function AuthenticatedModelPlatformApp() { selectedIdRef.current = nextSelectedId; return nextSelectedId; }); + // 同时更新打开的标签页 + setOpenTabIds((current) => { + const firstNotebook = items.find((item) => item.script_type === "notebook")?.script_id + ?? items[0]?.script_id; + if (!firstNotebook) return []; + // 如果当前标签页已经包含,则保持不变 + if (current.includes(firstNotebook)) return current; + return [firstNotebook]; + }); } catch (error) { setApiOnline(false); setToast({ @@ -200,6 +209,20 @@ function AuthenticatedModelPlatformApp() { void load(); }, []); + // 切换 Workspace 时重置状态并重新加载 + useEffect(() => { + setScripts([]); + setDirectories([]); + setSelectedId(null); + setOpenTabIds([]); + setLatestVersion(null); + setEmbeddedJupyterUrl(null); + setEditSession(null); + editSessionRef.current = null; + selectedIdRef.current = null; + void load(); + }, [currentWorkspace.workspace_id]); + useEffect(() => { if (!toast) return; const timer = window.setTimeout(() => setToast(null), 3200);