fix(knowledgeBase): improve navigation and folder tree refresh logic

- Add path comparison check in breadcrumb navigation to avoid unnecessary route changes when already on target page
- Implement delayed folder tree refresh with setTimeout to ensure state reset completes before refreshing
- Add manual table refresh trigger to ensure data updates after navigation
- Reset expanded keys in FolderTree component during load to ensure consistent state from root directory
- Add expanded keys reset in breadcrumb navigation to prevent stale expansion state
- Improve navigation state handling by using replace flag only when on target path to reduce history stack pollution
This commit is contained in:
yujiangping
2025-12-26 10:24:26 +08:00
parent c00e164567
commit 9f647e8357
3 changed files with 32 additions and 6 deletions

View File

@@ -213,10 +213,23 @@ export const useBreadcrumbManager = (options?: BreadcrumbOptions) => {
refresh: true, // 添加刷新标志
timestamp: Date.now(), // 添加时间戳确保状态变化
};
navigate(`/knowledge-base/${breadcrumbPath.knowledgeBase!.id}/private`, {
state: navigationState,
replace: true // 使用 replace 避免历史记录堆积
});
// 使用当前页面路径进行导航,避免不必要的路由变化
const currentPath = window.location.pathname;
const targetPath = `/knowledge-base/${breadcrumbPath.knowledgeBase!.id}/private`;
if (currentPath === targetPath) {
// 如果已经在目标页面,直接更新状态而不导航
navigate(targetPath, {
state: navigationState,
replace: true // 使用 replace 避免历史记录堆积
});
} else {
// 如果不在目标页面,正常导航
navigate(targetPath, {
state: navigationState
});
}
return false;
},
}] : []),