fix:切换空间脚本目录未更新问题
This commit is contained in:
@@ -184,6 +184,15 @@ function AuthenticatedModelPlatformApp() {
|
|||||||
selectedIdRef.current = nextSelectedId;
|
selectedIdRef.current = nextSelectedId;
|
||||||
return 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) {
|
} catch (error) {
|
||||||
setApiOnline(false);
|
setApiOnline(false);
|
||||||
setToast({
|
setToast({
|
||||||
@@ -200,6 +209,20 @@ function AuthenticatedModelPlatformApp() {
|
|||||||
void load();
|
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(() => {
|
useEffect(() => {
|
||||||
if (!toast) return;
|
if (!toast) return;
|
||||||
const timer = window.setTimeout(() => setToast(null), 3200);
|
const timer = window.setTimeout(() => setToast(null), 3200);
|
||||||
|
|||||||
Reference in New Issue
Block a user