fix:上传其他文件未自动更新

This commit is contained in:
xiaozhu
2026-09-01 16:30:19 +08:00
parent ac0893cdb5
commit 149e85cf10
2 changed files with 28 additions and 4 deletions
@@ -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<
}
},
};
};
};
function parentPathOfResource(path: string): string {
const parts = path.split("/");
parts.pop();
return parts.join("/");
}