fix:上传其他文件未自动更新
This commit is contained in:
@@ -264,8 +264,6 @@ export default function ScriptsPage() {
|
||||
visibility,
|
||||
description: description.trim(),
|
||||
targetPath: targetPath.trim(),
|
||||
}).then((resource) => {
|
||||
if (resource) void loadDataResources();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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",
|
||||
@@ -427,3 +447,9 @@ export const createMutationsSlice: StateCreator<
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
function parentPathOfResource(path: string): string {
|
||||
const parts = path.split("/");
|
||||
parts.pop();
|
||||
return parts.join("/");
|
||||
}
|
||||
Reference in New Issue
Block a user