From 149e85cf10cc83e9becc6e4d835be99eff5b04f9 Mon Sep 17 00:00:00 2001 From: xiaozhu <2395895331@qq.com> Date: Tue, 1 Sep 2026 16:30:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9C=AA=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/features/platform/ScriptsPage.tsx | 2 -- .../features/platform/state/mutationsSlice.ts | 30 +++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/frontend/app/features/platform/ScriptsPage.tsx b/frontend/app/features/platform/ScriptsPage.tsx index 3d8166c..ed95983 100644 --- a/frontend/app/features/platform/ScriptsPage.tsx +++ b/frontend/app/features/platform/ScriptsPage.tsx @@ -264,8 +264,6 @@ export default function ScriptsPage() { visibility, description: description.trim(), targetPath: targetPath.trim(), - }).then((resource) => { - if (resource) void loadDataResources(); }); }; diff --git a/frontend/app/features/platform/state/mutationsSlice.ts b/frontend/app/features/platform/state/mutationsSlice.ts index b0d0998..a4b1d54 100644 --- a/frontend/app/features/platform/state/mutationsSlice.ts +++ b/frontend/app/features/platform/state/mutationsSlice.ts @@ -7,7 +7,7 @@ // - createScript 写 scripts (scriptsSlice) + 调 openTab (selectionSlice) // - uploadScripts 写 scripts (scriptsSlice) + 调 openTab (selectionSlice) + // 调 load (scriptsSlice) -// - uploadDataResource 不写 store state (只走 uiStore) +// - uploadDataResource 写 dataResources (scriptsSlice) + 失效对应路径缓存 // - createFolder 写 loadedChildPaths/directories/expandedPaths (treeSlice) + // 调 loadChildren / load (treeSlice/scriptsSlice) // - deleteScript 写 openTabIds/selectedId (selectionSlice) + 调 @@ -175,6 +175,26 @@ export const createMutationsSlice: StateCreator< description: meta.description, visibility: meta.visibility, }); + // 与 uploadScripts 一致:直接写入 store。loadDataResources 有路径缓存, + // 上传后再调会命中已加载路径直接 return,列表不会更新。 + const parentPath = parentPathOfResource(resource.jupyter_accessible_path); + set((state) => { + const nextLoaded = new Set(state.loadedDataResourcePaths); + nextLoaded.delete(ownerCacheKey(resource.owner_user_id, parentPath)); + // targetPath 与 jupyter 父路径不一致时一并失效(例如带前缀差异)。 + if (meta.targetPath !== parentPath) { + nextLoaded.delete( + ownerCacheKey(resource.owner_user_id, meta.targetPath), + ); + } + const withoutDup = state.dataResources.filter( + (r) => r.resource_id !== resource.resource_id, + ); + return { + dataResources: [resource, ...withoutDup], + loadedDataResourcePaths: nextLoaded, + }; + }); ui.closeDataResourceDialog(); pushToast( "success", @@ -426,4 +446,10 @@ export const createMutationsSlice: StateCreator< } }, }; -}; \ No newline at end of file +}; + +function parentPathOfResource(path: string): string { + const parts = path.split("/"); + parts.pop(); + return parts.join("/"); +} \ No newline at end of file