fix: ui bugs

This commit is contained in:
Junyan Qin
2025-07-12 18:12:53 +08:00
parent a10e61735d
commit de76fed25a
5 changed files with 58 additions and 7 deletions

View File

@@ -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<string | undefined>(propKbId);
const [activeMenu, setActiveMenu] = useState('metadata');
const [fileId, setFileId] = useState<string | undefined>(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({
<Button
type="button"
variant="destructive"
onClick={onKbDeleted}
onClick={() => setShowDeleteConfirm(true)}
>
{t('common.delete')}
</Button>
@@ -208,6 +216,29 @@ export default function KBDetailDialog({
</SidebarProvider>
</DialogContent>
</Dialog>
{/* 删除确认对话框 */}
<Dialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
<DialogContent>
<DialogHeader>
<DialogTitle>{t('common.confirmDelete')}</DialogTitle>
</DialogHeader>
<div className="py-4">
{t('knowledge.deleteKnowledgeBaseConfirmation')}
</div>
<DialogFooter>
<Button
variant="outline"
onClick={() => setShowDeleteConfirm(false)}
>
{t('common.cancel')}
</Button>
<Button variant="destructive" onClick={confirmDelete}>
{t('common.confirmDelete')}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
);
}

View File

@@ -463,7 +463,9 @@ class HttpClient {
uuid: string,
file_id: string,
): Promise<object> {
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<object> {
return this.delete(`/api/v1/knowledge/bases/${uuid}`);
}
// ============ Plugins API ============
public getPlugins(): Promise<ApiRespPlugins> {
return this.get('/api/v1/plugins');

View File

@@ -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 👋',

View File

@@ -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 を初期化 👋',

View File

@@ -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 👋',