Skip to content

Conversation

yangxyo
Copy link
Contributor

@yangxyo yangxyo commented Jul 10, 2025

#5067
Fix the issue where the original page number was not preserved when returning to the knowledge base dataset file list after viewing file details.
(修复查看知识库数据集文件详情后返回列表时未保留原页码的问题)

…hen returning to the knowledge base dataset file list after viewing file details.
Copy link
Contributor

gru-agent bot commented Jul 10, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail 2db9ad3 🚫 Skipped No files need to be tested {"packages/web/hooks/usePagination.tsx":"File path does not match include patterns.","projects/app/src/pageComponents/dataset/detail/CollectionCard/Context.tsx":"File path does not match include patterns."}

History Assignment

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

Copy link

cla-assistant bot commented Jul 10, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


sweeney seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
Copy link

cla-assistant bot commented Jul 10, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


sweeney seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

github-actions bot commented Jul 10, 2025

Preview sandbox Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_sandbox_6e367bd97b78998426e1d6ab9e8b58ad8eb8bd8e

Copy link

github-actions bot commented Jul 10, 2025

Preview mcp_server Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_mcp_server_6e367bd97b78998426e1d6ab9e8b58ad8eb8bd8e

Copy link

github-actions bot commented Jul 10, 2025

Preview fastgpt Image:

registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-pr:fatsgpt_6e367bd97b78998426e1d6ab9e8b58ad8eb8bd8e

@@ -55,7 +57,7 @@ export function usePagination<DataT, ResT = {}>(

const fetchData = useMemoizedFn(
async (num: number = pageNum, ScrollContainerRef?: RefObject<HTMLDivElement>) => {
if (noMore && num !== 1) return;
if (noMore && num !== defaultPageNum) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边是不需要调整的,只需要 defaultPageNum 赋值到 useState 里即可

@@ -16,6 +16,8 @@ import { type WebsiteConfigFormType } from './WebsiteConfig';

const WebSiteConfigModal = dynamic(() => import('./WebsiteConfig'));

let defaultPageNum = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在外层的变量似乎是全局生效的,这么写会导致一个问题:

  • 切换到第 2 页集合。
  • 退出知识库
  • 再进入知识库
    可能会导致默认就是第二页了。

我觉得应该把 pageNum 写在 router query 里更好

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者写在 datasetContext 这个更大的上下文里

@yangxyo
Copy link
Contributor Author

yangxyo commented Jul 11, 2025

好的,感谢,我再看看

@pull-request-size pull-request-size bot added size/M and removed size/S labels Jul 11, 2025
@yangxyo
Copy link
Contributor Author

yangxyo commented Jul 11, 2025

  if (noMore && num !== defaultPageNum) return;

  async () => {
      defaultRequest && fetchData(defaultPageNum);
    },

需要说明的是以上两处修改经过测试是有必要的,返回通用触发了刷新。

@yangxyo
Copy link
Contributor Author

yangxyo commented Jul 16, 2025

@c121914yu 辛苦看看。

@c121914yu
Copy link
Collaborator

  if (noMore && num !== defaultPageNum) return;

  async () => {
      defaultRequest && fetchData(defaultPageNum);
    },

需要说明的是以上两处修改经过测试是有必要的,返回通用触发了刷新。

非第一页,返回就是需要触发刷新,这应该符合预期

@yangxyo
Copy link
Contributor Author

yangxyo commented Jul 17, 2025

之前这两处的defaultPageNum都写的1,如果不改成defaultPageNum还是都会返回第一页。

@c121914yu
Copy link
Collaborator

c121914yu commented Jul 17, 2025

之前这两处的defaultPageNum都写的1,如果不改成defaultPageNum还是都会返回第一页。

noMore && num !== defaultPageNum 不需要改,这个含义是第一页不管有没有更多数据,都会强制加载。

defaultRequest && fetchData(defaultPageNum) 改的话也会有问题,因为依赖刷新的话,应该就是要到 第一页(比如一些过滤条件刷新了,你可以测试下输入搜索词,这样改就不会跳回第一页了)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants