Enhance ComponentsKnowledgePage with improved dialog content and layout

- Add DialogDescription components to provide context in the settings and search dialogs.
- Refactor layout for better spacing and organization of form elements in the settings dialog.
- Update search results display to improve user experience with clearer messaging and styling.
- Introduce footer buttons for closing dialogs, enhancing user interaction.
This commit is contained in:
Xin Wang
2026-07-12 18:26:34 +08:00
parent 5d52ce8380
commit 0536930fde

View File

@@ -27,6 +27,7 @@ import { DataList } from "@/components/ui/data-list";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
@@ -975,29 +976,28 @@ function KnowledgeEditView({ knowledgeBaseId }: { knowledgeBaseId: string }) {
</Card>
<Dialog open={settingsOpen} onOpenChange={setSettingsOpen}>
<DialogContent>
<DialogContent className="sm:max-w-xl">
<DialogHeader>
<DialogTitle></DialogTitle>
<DialogDescription>
Embedding
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
<label className="block">
<div className="mb-2 text-sm font-medium text-foreground">
</div>
<div className="space-y-5 rounded-xl border border-hairline bg-surface-strong/20 p-4">
<label className="block space-y-2">
<span className="text-sm font-medium"></span>
<Textarea
placeholder="用途说明(可选)"
value={description}
onChange={(event) => setDescription(event.target.value)}
rows={4}
className="field-sizing-fixed min-h-24 resize-y border-hairline-strong bg-background"
className="field-sizing-fixed min-h-24 resize-y"
/>
</label>
<div>
<div className="mb-2 text-sm font-medium text-foreground">
Embedding
</div>
<label className="block space-y-2">
<span className="text-sm font-medium">Embedding </span>
<Select value={embeddingId} onValueChange={setEmbeddingId}>
<SelectTrigger className="border-hairline-strong bg-background">
<SelectTrigger className="w-full">
<SelectValue placeholder="选择 Embedding 模型" />
</SelectTrigger>
<SelectContent>
@@ -1009,13 +1009,16 @@ function KnowledgeEditView({ knowledgeBaseId }: { knowledgeBaseId: string }) {
</SelectContent>
</Select>
{documents.length > 0 && (
<p className="mt-2 text-xs text-muted-foreground">
<p className="text-xs text-muted-foreground">
Embedding
</p>
)}
</div>
</label>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => setSettingsOpen(false)}>
</Button>
<Button
disabled={busy || !embeddingId}
onClick={() => void saveSettings()}
@@ -1028,17 +1031,16 @@ function KnowledgeEditView({ knowledgeBaseId }: { knowledgeBaseId: string }) {
</Dialog>
<Dialog open={searchOpen} onOpenChange={setSearchOpen}>
<DialogContent className="sm:max-w-2xl">
<DialogContent className="max-h-[calc(100vh-3rem)] overflow-y-auto sm:max-w-3xl">
<DialogHeader>
<DialogTitle></DialogTitle>
<DialogDescription>
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
<p className="text-sm text-muted-foreground">
</p>
<div className="flex gap-2">
<Input
className="border-hairline-strong bg-background"
placeholder="输入问题,例如:退款规则是什么?"
value={testQuery}
onChange={(event) => setTestQuery(event.target.value)}
@@ -1047,6 +1049,7 @@ function KnowledgeEditView({ knowledgeBaseId }: { knowledgeBaseId: string }) {
}}
/>
<Button
className="shrink-0 gap-2"
disabled={searching || !testQuery.trim()}
onClick={() => void testSearch()}
>
@@ -1058,29 +1061,36 @@ function KnowledgeEditView({ knowledgeBaseId }: { knowledgeBaseId: string }) {
</Button>
</div>
<div className="max-h-[50vh] space-y-3 overflow-y-auto">
{searchResults.length === 0 ? (
<p className="py-4 text-center text-sm text-muted-foreground">
</p>
) : (
searchResults.map((result, index) => (
{searchResults.length === 0 ? (
<div className="rounded-xl border border-dashed border-hairline-strong px-4 py-10 text-center text-sm text-muted-foreground">
</div>
) : (
<div className="max-h-[50vh] divide-y divide-hairline overflow-y-auto rounded-xl border border-hairline">
{searchResults.map((result, index) => (
<div
key={`${result.document}-${index}`}
className="rounded-xl border border-hairline p-3"
className="space-y-2 px-4 py-3"
>
<div className="mb-2 flex justify-between text-xs text-muted-foreground">
<span>{result.document}</span>
<span> {result.score}</span>
<div className="flex justify-between gap-3 text-xs text-muted-foreground">
<span className="truncate">{result.document}</span>
<span className="shrink-0 tabular-nums">
{result.score}
</span>
</div>
<p className="whitespace-pre-wrap text-sm leading-6">
<p className="whitespace-pre-wrap text-sm leading-6 text-foreground">
{result.content}
</p>
</div>
))
)}
</div>
))}
</div>
)}
</div>
<DialogFooter>
<Button variant="outline" onClick={() => setSearchOpen(false)}>
</Button>
</DialogFooter>
</DialogContent>
</Dialog>