From de76fed25a71fb969fcbb6edb71b6d2054478724 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Sat, 12 Jul 2025 18:12:53 +0800 Subject: [PATCH] fix: ui bugs --- web/src/app/home/knowledge/KBDetailDialog.tsx | 37 +++++++++++++++++-- web/src/app/infra/http/HttpClient.ts | 8 +++- web/src/i18n/locales/en-US.ts | 4 +- web/src/i18n/locales/ja-JP.ts | 8 +++- web/src/i18n/locales/zh-Hans.ts | 8 +++- 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/web/src/app/home/knowledge/KBDetailDialog.tsx b/web/src/app/home/knowledge/KBDetailDialog.tsx index d31306bd..3854e933 100644 --- a/web/src/app/home/knowledge/KBDetailDialog.tsx +++ b/web/src/app/home/knowledge/KBDetailDialog.tsx @@ -7,6 +7,7 @@ import { DialogHeader, DialogTitle, DialogFooter, + DialogDescription, } from '@/components/ui/dialog'; import { Sidebar, @@ -21,7 +22,7 @@ import { import { Button } from '@/components/ui/button'; import { useTranslation } from 'react-i18next'; import { z } from 'zod'; -// import { httpClient } from '@/app/infra/http/HttpClient'; +import { httpClient } from '@/app/infra/http/HttpClient'; // import { KnowledgeBase } from '@/app/infra/entities/api'; import KBForm from '@/app/home/knowledge/components/kb-form/KBForm'; import KBDoc from '@/app/home/knowledge/components/kb-docs/KBDoc'; @@ -50,7 +51,7 @@ export default function KBDetailDialog({ const [kbId, setKbId] = useState(propKbId); const [activeMenu, setActiveMenu] = useState('metadata'); const [fileId, setFileId] = useState(undefined); - // const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); + const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); useEffect(() => { setKbId(propKbId); @@ -86,6 +87,13 @@ export default function KBDetailDialog({ }, ]; + const confirmDelete = () => { + httpClient.deleteKnowledgeBase(kbId ?? '').then(() => { + onKbDeleted(); + }); + setShowDeleteConfirm(false); + }; + if (!kbId) { // new kb return ( @@ -187,7 +195,7 @@ export default function KBDetailDialog({ @@ -208,6 +216,29 @@ export default function KBDetailDialog({ + + {/* 删除确认对话框 */} + + + + {t('common.confirmDelete')} + +
+ {t('knowledge.deleteKnowledgeBaseConfirmation')} +
+ + + + +
+
); } diff --git a/web/src/app/infra/http/HttpClient.ts b/web/src/app/infra/http/HttpClient.ts index a2d42f66..d3530a4e 100644 --- a/web/src/app/infra/http/HttpClient.ts +++ b/web/src/app/infra/http/HttpClient.ts @@ -463,7 +463,9 @@ class HttpClient { uuid: string, file_id: string, ): Promise { - return this.delete(`/api/v1/knowledge/bases/${uuid}/files/${file_id}`); + return this.post(`/api/v1/knowledge/bases/${uuid}/files`, { + file_id, + }); } public getKnowledgeBaseFiles( @@ -479,6 +481,10 @@ class HttpClient { return this.delete(`/api/v1/knowledge/bases/${uuid}/files/${file_id}`); } + public deleteKnowledgeBase(uuid: string): Promise { + return this.delete(`/api/v1/knowledge/bases/${uuid}`); + } + // ============ Plugins API ============ public getPlugins(): Promise { return this.get('/api/v1/plugins'); diff --git a/web/src/i18n/locales/en-US.ts b/web/src/i18n/locales/en-US.ts index 53729084..8e6d7b49 100644 --- a/web/src/i18n/locales/en-US.ts +++ b/web/src/i18n/locales/en-US.ts @@ -254,7 +254,7 @@ const enUS = { documentsTab: { name: 'Name', status: 'Status', - noResults: 'No results', + noResults: 'No documents', dragAndDrop: 'Drag and drop files here or click to upload', uploading: 'Uploading...', supportedFormats: @@ -267,6 +267,8 @@ const enUS = { fileDeleteSuccess: 'File deleted successfully', fileDeleteFailed: 'File deletion failed', }, + deleteKnowledgeBaseConfirmation: + 'Are you sure you want to delete this knowledge base? All documents in this knowledge base will be deleted.', }, register: { title: 'Initialize LangBot 👋', diff --git a/web/src/i18n/locales/ja-JP.ts b/web/src/i18n/locales/ja-JP.ts index 639549b1..c0e70806 100644 --- a/web/src/i18n/locales/ja-JP.ts +++ b/web/src/i18n/locales/ja-JP.ts @@ -256,7 +256,7 @@ const jaJP = { documentsTab: { name: '名前', status: 'ステータス', - noResults: '結果がありません', + noResults: 'ドキュメントがありません', dragAndDrop: 'ファイルをここにドラッグ&ドロップするか、クリックしてアップロードしてください', uploading: 'アップロード中...', @@ -265,7 +265,13 @@ const jaJP = { uploadSuccess: 'ファイルのアップロードに成功しました!', uploadError: 'ファイルのアップロードに失敗しました。再度お試しください', uploadingFile: 'ファイルをアップロード中...', + actions: 'アクション', + delete: 'ドキュメントを削除', + fileDeleteSuccess: 'ドキュメントの削除に成功しました', + fileDeleteFailed: 'ドキュメントの削除に失敗しました', }, + deleteKnowledgeBaseConfirmation: + '本当にこの知識ベースを削除しますか?この知識ベースに紐付けられたドキュメントは削除されます。', }, register: { title: 'LangBot を初期化 👋', diff --git a/web/src/i18n/locales/zh-Hans.ts b/web/src/i18n/locales/zh-Hans.ts index 71089fa2..28574fdf 100644 --- a/web/src/i18n/locales/zh-Hans.ts +++ b/web/src/i18n/locales/zh-Hans.ts @@ -248,14 +248,20 @@ const zhHans = { documentsTab: { name: '名称', status: '状态', - noResults: '暂无结果', + noResults: '暂无文档', dragAndDrop: '拖拽文件到此处或点击上传', uploading: '上传中...', supportedFormats: '支持 PDF、Word、TXT、Markdown 等文档格式', uploadSuccess: '文件上传成功!', uploadError: '文件上传失败,请重试', uploadingFile: '上传文件中...', + actions: '操作', + delete: '删除文件', + fileDeleteSuccess: '文件删除成功', + fileDeleteFailed: '文件删除失败', }, + deleteKnowledgeBaseConfirmation: + '你确定要删除这个知识库吗?此知识库下的所有文档将被删除。', }, register: { title: '初始化 LangBot 👋',