@@ -6,30 +6,30 @@ import { SyncOutlined, PlusOutlined } from '@ant-design/icons'
66
77import { KnowledgeBase } from '@/types/knowledgeBase'
88
9- // 知识库布局常量配置
9+ // Knowledge base layout constants configuration
1010const KB_LAYOUT = {
11- // 知识库行高配置
12- ROW_PADDING : 'py-4' , // 行垂直内边距
13- HEADER_PADDING : 'p-3' , // 列表头部内边距
14- BUTTON_PADDING : 'p-2' , // 创建按钮区域内边距
15- TAG_SPACING : 'gap-0.5' , // 标签之间的间距
16- TAG_MARGIN : 'mt-2.5' , // 标签容器上边距
17- // 标签相关配置
18- TAG_PADDING : 'px-1.5 py-0.5' , // 标签内边距
19- TAG_TEXT : 'text-xs font-medium' , // 标签文字样式
20- TAG_ROUNDED : 'rounded-md' , // 标签圆角
21- // 换行相关配置
22- TAG_BREAK_HEIGHT : 'h-0.5' , // 换行间隔高度
23- SECOND_ROW_TAG_MARGIN : 'mt-0.5' , // 第二行标签上边距
24- // 其他布局配置
25- TITLE_MARGIN : 'ml-2' , // 标题左边距
26- EMPTY_STATE_PADDING : 'py-4' , // 空状态内边距
27- // 标题相关配置
28- TITLE_TEXT : 'text-xl font-bold' , // 标题文字样式
29- KB_NAME_TEXT : 'text-lg font-medium' , // 知识库名称文字样式
30- // 知识库名称配置
31- KB_NAME_MAX_WIDTH : '220px' , // 知识库名称最大宽度
32- KB_NAME_OVERFLOW : { // 知识库名称溢出样式
11+ // Knowledge base row height configuration
12+ ROW_PADDING : 'py-4' , // Row vertical padding
13+ HEADER_PADDING : 'p-3' , // List header padding
14+ BUTTON_PADDING : 'p-2' , // Create button area padding
15+ TAG_SPACING : 'gap-0.5' , // Spacing between tags
16+ TAG_MARGIN : 'mt-2.5' , // Tag container top margin
17+ // Tag related configuration
18+ TAG_PADDING : 'px-1.5 py-0.5' , // Tag padding
19+ TAG_TEXT : 'text-xs font-medium' , // Tag text style
20+ TAG_ROUNDED : 'rounded-md' , // Tag rounded corners
21+ // Line break related configuration
22+ TAG_BREAK_HEIGHT : 'h-0.5' , // Line break interval height
23+ SECOND_ROW_TAG_MARGIN : 'mt-0.5' , // Second row tag top margin
24+ // Other layout configuration
25+ TITLE_MARGIN : 'ml-2' , // Title left margin
26+ EMPTY_STATE_PADDING : 'py-4' , // Empty state padding
27+ // Title related configuration
28+ TITLE_TEXT : 'text-xl font-bold' , // Title text style
29+ KB_NAME_TEXT : 'text-lg font-medium' , // Knowledge base name text style
30+ // Knowledge base name configuration
31+ KB_NAME_MAX_WIDTH : '220px' , // Knowledge base name max width
32+ KB_NAME_OVERFLOW : { // Knowledge base name overflow style
3333 textOverflow : 'ellipsis' ,
3434 whiteSpace : 'nowrap' ,
3535 overflow : 'hidden' ,
@@ -50,8 +50,8 @@ interface KnowledgeBaseListProps {
5050 onCreateNew : ( ) => void
5151 isSelectable : ( kb : KnowledgeBase ) => boolean
5252 getModelDisplayName : ( modelId : string ) => string
53- containerHeight ?: string // 容器总高度,与DocumentList保持一致
54- onKnowledgeBaseChange ?: ( ) => void // 新增:知识库切换时的回调函数
53+ containerHeight ?: string // Container total height, consistent with DocumentList
54+ onKnowledgeBaseChange ?: ( ) => void // New: callback function when knowledge base switches
5555}
5656
5757const KnowledgeBaseList : React . FC < KnowledgeBaseListProps > = ( {
@@ -67,25 +67,25 @@ const KnowledgeBaseList: React.FC<KnowledgeBaseListProps> = ({
6767 onCreateNew,
6868 isSelectable,
6969 getModelDisplayName,
70- containerHeight = '70vh' , // 默认与DocumentList一致的容器高度
71- onKnowledgeBaseChange // 新增:知识库切换时的回调函数
70+ containerHeight = '70vh' , // Default container height consistent with DocumentList
71+ onKnowledgeBaseChange // New: callback function when knowledge base switches
7272} ) => {
7373 const { t } = useTranslation ( ) ;
7474
75- // 格式化日期函数,只保留日期部分
75+ // Format date function, only keep date part
7676 const formatDate = ( dateString : number ) => {
7777 try {
7878 const date = new Date ( dateString ) ;
79- return date . toISOString ( ) . split ( 'T' ) [ 0 ] ; // 只返回YYYY -MM-DD部分
79+ return date . toISOString ( ) . split ( 'T' ) [ 0 ] ; // Only return YYYY -MM-DD part
8080 } catch ( e ) {
81- return dateString ; // 如果解析失败,返回原始字符串
81+ return dateString ; // If parsing fails, return original string
8282 }
8383 } ;
8484
8585
8686 return (
8787 < div className = "w-full bg-white border border-gray-200 rounded-md flex flex-col" style = { { height : containerHeight } } >
88- { /* 固定的头部区域 */ }
88+ { /* Fixed header area */ }
8989 < div className = { `${ KB_LAYOUT . HEADER_PADDING } border-b border-gray-200 shrink-0` } >
9090 < div className = "flex items-center justify-between" >
9191 < div >
@@ -142,7 +142,7 @@ const KnowledgeBaseList: React.FC<KnowledgeBaseListProps> = ({
142142 </ div >
143143 </ div >
144144
145- { /* 固定的选择状态区域 */ }
145+ { /* Fixed selection status area */ }
146146 < div className = "border-b border-gray-200 shrink-0 relative z-10 shadow-md" >
147147 < div className = "px-5 py-2 bg-blue-50" >
148148 < div className = "flex items-center" >
@@ -186,7 +186,7 @@ const KnowledgeBaseList: React.FC<KnowledgeBaseListProps> = ({
186186 </ div >
187187 </ div >
188188
189- { /* 可滚动的知识库列表区域 */ }
189+ { /* Scrollable knowledge base list area */ }
190190 < div className = "flex-1 overflow-y-auto overflow-x-hidden" >
191191 { knowledgeBases . length > 0 ? (
192192 < div className = "divide-y-0" >
@@ -272,30 +272,30 @@ const KnowledgeBaseList: React.FC<KnowledgeBaseListProps> = ({
272272 </ button >
273273 </ div >
274274 < div className = { `flex flex-wrap items-center ${ KB_LAYOUT . TAG_MARGIN } ${ KB_LAYOUT . TAG_SPACING } ` } >
275- { /* 文档数量标签 */ }
275+ { /* Document count tag */ }
276276 < span className = { `inline-flex items-center ${ KB_LAYOUT . TAG_PADDING } ${ KB_LAYOUT . TAG_ROUNDED } ${ KB_LAYOUT . TAG_TEXT } bg-gray-200 text-gray-800 border border-gray-200 mr-1` } >
277277 { t ( 'knowledgeBase.tag.documents' , { count : kb . documentCount || 0 } ) }
278278 </ span >
279279
280- { /* 分块数量标签 */ }
280+ { /* Chunk count tag */ }
281281 < span className = { `inline-flex items-center ${ KB_LAYOUT . TAG_PADDING } ${ KB_LAYOUT . TAG_ROUNDED } ${ KB_LAYOUT . TAG_TEXT } bg-gray-200 text-gray-800 border border-gray-200 mr-1` } >
282282 { t ( 'knowledgeBase.tag.chunks' , { count : kb . chunkCount || 0 } ) }
283283 </ span >
284284
285- { /* 知识库来源标签 */ }
285+ { /* Knowledge base source tag */ }
286286 < span className = { `inline-flex items-center ${ KB_LAYOUT . TAG_PADDING } ${ KB_LAYOUT . TAG_ROUNDED } ${ KB_LAYOUT . TAG_TEXT } bg-gray-200 text-gray-800 border border-gray-200 mr-1` } >
287287 { t ( 'knowledgeBase.tag.source' , { source : kb . source } ) }
288288 </ span >
289289
290- { /* 创建日期标签 - 只显示日期 */ }
290+ { /* Creation date tag - only show date */ }
291291 < span className = { `inline-flex items-center ${ KB_LAYOUT . TAG_PADDING } ${ KB_LAYOUT . TAG_ROUNDED } ${ KB_LAYOUT . TAG_TEXT } bg-gray-200 text-gray-800 border border-gray-200 mr-1` } >
292292 { t ( 'knowledgeBase.tag.createdAt' , { date : formatDate ( kb . createdAt ) } ) }
293293 </ span >
294294
295- { /* 强制换行 */ }
295+ { /* Force line break */ }
296296 < div className = { `w-full ${ KB_LAYOUT . TAG_BREAK_HEIGHT } ` } > </ div >
297297
298- { /* 模型标签 - 显示正常或不匹配 */ }
298+ { /* Model tag - show normal or mismatch */ }
299299 < span className = { `inline-flex items-center ${ KB_LAYOUT . TAG_PADDING } ${ KB_LAYOUT . TAG_ROUNDED } ${ KB_LAYOUT . TAG_TEXT } ${ KB_LAYOUT . SECOND_ROW_TAG_MARGIN } bg-green-100 text-green-800 border border-green-200 mr-1` } >
300300 { t ( 'knowledgeBase.tag.model' , { model : getModelDisplayName ( kb . embeddingModel ) } ) }
301301 </ span >
0 commit comments