From cf182317130438109e84004a7dd62fbd8bff5189 Mon Sep 17 00:00:00 2001 From: chanx <1243304602@qq.com> Date: Mon, 8 Sep 2025 12:49:12 +0800 Subject: [PATCH] Fix: Optimized the test results page layout and internationalization #3221 (#9974) ### What problem does this PR solve? Fix: Optimized the test results page layout and internationalization - Added an empty data component for when test results are empty - Optimized internationalization support for the paging component - Updated the layout and style of the test results page - Added a tooltip for when test results are empty ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- web/src/components/empty/empty.tsx | 77 +++++++++++++++++++ web/src/components/ui/ragflow-pagination.tsx | 9 ++- web/src/hooks/use-knowledge-request.ts | 4 +- web/src/interfaces/database/knowledge.ts | 1 + web/src/locales/en.ts | 9 +++ web/src/locales/zh.ts | 7 ++ .../dataset/dataset/parsing-status-cell.tsx | 2 +- web/src/pages/dataset/testing/index.tsx | 5 +- .../pages/dataset/testing/testing-result.tsx | 53 +++++++++---- web/src/pages/next-search/search-view.tsx | 2 +- 10 files changed, 149 insertions(+), 20 deletions(-) create mode 100644 web/src/components/empty/empty.tsx diff --git a/web/src/components/empty/empty.tsx b/web/src/components/empty/empty.tsx new file mode 100644 index 000000000..b32d25c5c --- /dev/null +++ b/web/src/components/empty/empty.tsx @@ -0,0 +1,77 @@ +import { cn } from '@/lib/utils'; +import { t } from 'i18next'; + +type EmptyProps = { + className?: string; + children?: React.ReactNode; +}; + +const EmptyIcon = () => ( + + {t('common.noData')} + + + + + + + + + + + + + + + +); + +const Empty = (props: EmptyProps) => { + const { className, children } = props; + return ( +
+ + {!children && ( +
+ {t('common.noData')} +
+ )} + {children} +
+ ); +}; + +export default Empty; diff --git a/web/src/components/ui/ragflow-pagination.tsx b/web/src/components/ui/ragflow-pagination.tsx index 3ef7749be..0eb013556 100644 --- a/web/src/components/ui/ragflow-pagination.tsx +++ b/web/src/components/ui/ragflow-pagination.tsx @@ -9,6 +9,7 @@ import { } from '@/components/ui/pagination'; import { RAGFlowSelect, RAGFlowSelectOptionType } from '@/components/ui/select'; import { cn } from '@/lib/utils'; +import { t } from 'i18next'; import { useCallback, useEffect, useMemo, useState } from 'react'; export type RAGFlowPaginationType = { @@ -32,7 +33,11 @@ export function RAGFlowPagination({ const sizeChangerOptions: RAGFlowSelectOptionType[] = useMemo(() => { return [10, 20, 50, 100].map((x) => ({ - label: {x} / page, + label: ( + + {x} / {t('pagination.page')} + + ), value: x.toString(), })); }, []); @@ -134,7 +139,7 @@ export function RAGFlowPagination({ return (
- Total {total} + {t('pagination.total', { total: total })} diff --git a/web/src/hooks/use-knowledge-request.ts b/web/src/hooks/use-knowledge-request.ts index cda325ccb..3251afe79 100644 --- a/web/src/hooks/use-knowledge-request.ts +++ b/web/src/hooks/use-knowledge-request.ts @@ -72,12 +72,14 @@ export const useTestRetrieval = () => { chunks: [], doc_aggs: [], total: 0, + isRuned: false, }, enabled: false, gcTime: 0, queryFn: async () => { const { data } = await kbService.retrieval_test(queryParams); - return data?.data ?? {}; + const result = data?.data ?? {}; + return { ...result, isRuned: true }; }, }); diff --git a/web/src/interfaces/database/knowledge.ts b/web/src/interfaces/database/knowledge.ts index 011f8a9eb..0d8fc025e 100644 --- a/web/src/interfaces/database/knowledge.ts +++ b/web/src/interfaces/database/knowledge.ts @@ -150,6 +150,7 @@ export interface INextTestingResult { doc_aggs: ITestingDocument[]; total: number; labels?: Record; + isRuned?: boolean; } export type IRenameTag = { fromTag: string; toTag: string }; diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index b94d1c9c5..b22a91127 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -46,6 +46,7 @@ export default { remove: 'Remove', search: 'Search', noDataFound: 'No data found.', + noData: 'No data', promptPlaceholder: `Please input or use / to quickly insert variables.`, mcp: { namePlaceholder: 'My MCP Server', @@ -138,6 +139,10 @@ export default { processBeginAt: 'Begin at', processDuration: 'Duration', progressMsg: 'Progress', + noTestResultsForRuned: + 'No relevant results found. Try adjusting your query or parameters.', + noTestResultsForNotRuned: + 'No test has been run yet. Results will appear here.', testingDescription: 'Conduct a retrieval test to check if RAGFlow can recover the intended content for the LLM. If you have adjusted the default settings, such as keyword similarity weight or similarity threshold, to achieve the optimal results, be aware that these changes will not be automatically saved. You must apply them to your chat assistant settings or the Retrieval agent component settings.', similarityThreshold: 'Similarity threshold', @@ -1579,5 +1584,9 @@ This delimiter is used to split the input text into several text pieces echo of korean: 'Korean', vietnamese: 'Vietnamese', }, + pagination: { + total: 'Total {{total}}', + page: 'Page', + }, }, }; diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index bfae19a6b..b8084fda7 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -45,6 +45,7 @@ export default { remove: '移除', search: '搜索', noDataFound: '没有找到数据。', + noData: '暂无数据', promptPlaceholder: '请输入或使用 / 快速插入变量。', }, login: { @@ -129,6 +130,8 @@ export default { processBeginAt: '开始于', processDuration: '持续时间', progressMsg: '进度', + noTestResultsForRuned: '未找到相关结果,请尝试调整查询语句或参数', + noTestResultsForNotRuned: '尚未运行测试,结果会显示在这里', testingDescription: '请完成召回测试:确保你的配置可以从数据库召回正确的文本块。如果你调整了这里的默认设置,比如关键词相似度权重,请注意这里的改动不会被自动保存。请务必在聊天助手设置或者召回算子设置处同步更新相关设置。', similarityThreshold: '相似度阈值', @@ -1493,5 +1496,9 @@ General:实体和关系提取提示来自 GitHub - microsoft/graphrag:基于 korean: '韩语', vietnamese: '越南语', }, + pagination: { + total: '总共 {{total}} 条', + page: '页', + }, }, }; diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.tsx index 2b3abd66e..8ada0b09d 100644 --- a/web/src/pages/dataset/dataset/parsing-status-cell.tsx +++ b/web/src/pages/dataset/dataset/parsing-status-cell.tsx @@ -67,7 +67,7 @@ export function ParsingStatusCell({ return (
-
+
*/}
@@ -51,6 +51,7 @@ export default function RetrievalTesting() { ; export function TestingResult({ @@ -45,6 +47,7 @@ export function TestingResult({ handleFilterSubmit, page, pageSize, + loading, onPaginationChange, data, }: TestingResultProps) { @@ -77,20 +80,42 @@ export function TestingResult({ -
- {data.chunks?.map((x) => ( - - -

{x.content_with_weight}

-
- ))} -
- + {data.chunks?.length > 0 && !loading && ( + <> +
+ {data.chunks?.map((x) => ( + + +

{x.content_with_weight}

+
+ ))} +
+ + + )} + {!data.chunks?.length && !loading && ( +
+
+ + {data.isRuned && ( +
+ {t('knowledgeDetails.noTestResultsForRuned')} +
+ )} + {!data.isRuned && ( +
+ {t('knowledgeDetails.noTestResultsForNotRuned')} +
+ )} +
+
+
+ )} ); } diff --git a/web/src/pages/next-search/search-view.tsx b/web/src/pages/next-search/search-view.tsx index 6c69dace3..fe1bb0d7f 100644 --- a/web/src/pages/next-search/search-view.tsx +++ b/web/src/pages/next-search/search-view.tsx @@ -262,7 +262,7 @@ export default function SearchingView({ {total > 0 && ( -
+