perf(retrieve): ui

This commit is contained in:
Junyan Qin
2025-07-20 17:57:33 +08:00
parent dd1ec15a39
commit 10a3cb40e1
4 changed files with 35 additions and 24 deletions

View File

@@ -37,6 +37,7 @@ export default function KBRetrieve({ kbId }: KBRetrieveProps) {
setLoading(true); setLoading(true);
try { try {
setResults([]);
const response = await httpClient.retrieveKnowledgeBase(kbId, query); const response = await httpClient.retrieveKnowledgeBase(kbId, query);
setResults(response.results); setResults(response.results);
} catch (error) { } catch (error) {
@@ -62,20 +63,19 @@ export default function KBRetrieve({ kbId }: KBRetrieveProps) {
onKeyPress={(e) => e.key === 'Enter' && handleRetrieve()} onKeyPress={(e) => e.key === 'Enter' && handleRetrieve()}
/> />
<Button onClick={handleRetrieve} disabled={loading || !query.trim()}> <Button onClick={handleRetrieve} disabled={loading || !query.trim()}>
{loading ? t('common.loading') : t('knowledge.query')} {t('knowledge.query')}
</Button> </Button>
</div> </div>
<div className="space-y-3"> <div className="space-y-3">
<h3 className="text-lg font-semibold">
{t('knowledge.retrieveResults')} ({results.length})
</h3>
{results.length === 0 && !loading && ( {results.length === 0 && !loading && (
<p className="text-muted-foreground">{t('knowledge.noResults')}</p> <p className="text-muted-foreground">{t('knowledge.noResults')}</p>
)} )}
{results.map((result) => ( {loading ? (
<p className="text-muted-foreground">{t('common.loading')}</p>
) : (
results.map((result) => (
<Card key={result.id} className="w-full"> <Card key={result.id} className="w-full">
<CardHeader className="pb-3"> <CardHeader className="pb-3">
<CardTitle className="text-sm font-medium flex justify-between items-center"> <CardTitle className="text-sm font-medium flex justify-between items-center">
@@ -91,7 +91,8 @@ export default function KBRetrieve({ kbId }: KBRetrieveProps) {
</p> </p>
</CardContent> </CardContent>
</Card> </Card>
))} ))
)}
</div> </div>
</div> </div>
); );

View File

@@ -40,6 +40,7 @@ const enUS = {
copySuccess: 'Copy Successfully', copySuccess: 'Copy Successfully',
test: 'Test', test: 'Test',
forgotPassword: 'Forgot Password?', forgotPassword: 'Forgot Password?',
loading: 'Loading...',
}, },
notFound: { notFound: {
title: 'Page not found', title: 'Page not found',
@@ -286,7 +287,6 @@ const enUS = {
retrieveTest: 'Retrieve Test', retrieveTest: 'Retrieve Test',
query: 'Query', query: 'Query',
queryPlaceholder: 'Enter query text...', queryPlaceholder: 'Enter query text...',
retrieveResults: 'Retrieve Results',
distance: 'Distance', distance: 'Distance',
content: 'Content', content: 'Content',
fileName: 'File Name', fileName: 'File Name',

View File

@@ -41,6 +41,7 @@ const jaJP = {
copySuccess: 'コピーに成功しました', copySuccess: 'コピーに成功しました',
test: 'テスト', test: 'テスト',
forgotPassword: 'パスワードを忘れた?', forgotPassword: 'パスワードを忘れた?',
loading: '読み込み中...',
}, },
notFound: { notFound: {
title: 'ページが見つかりません', title: 'ページが見つかりません',
@@ -285,6 +286,15 @@ const jaJP = {
}, },
deleteKnowledgeBaseConfirmation: deleteKnowledgeBaseConfirmation:
'本当にこの知識ベースを削除しますか?この知識ベースに紐付けられたドキュメントは削除されます。', '本当にこの知識ベースを削除しますか?この知識ベースに紐付けられたドキュメントは削除されます。',
retrieve: '検索テスト',
retrieveTest: '検索テスト',
query: '検索',
queryPlaceholder: '検索内容を入力...',
distance: '距離',
content: '内容',
fileName: 'ファイル名',
noResults: '検索結果がありません',
retrieveError: '検索に失敗しました',
}, },
register: { register: {
title: 'LangBot を初期化 👋', title: 'LangBot を初期化 👋',

View File

@@ -40,6 +40,7 @@ const zhHans = {
copySuccess: '复制成功', copySuccess: '复制成功',
test: '测试', test: '测试',
forgotPassword: '忘记密码?', forgotPassword: '忘记密码?',
loading: '加载中...',
}, },
notFound: { notFound: {
title: '页面不存在', title: '页面不存在',
@@ -278,7 +279,6 @@ const zhHans = {
retrieveTest: '检索测试', retrieveTest: '检索测试',
query: '查询', query: '查询',
queryPlaceholder: '输入查询内容...', queryPlaceholder: '输入查询内容...',
retrieveResults: '检索结果',
distance: '距离', distance: '距离',
content: '内容', content: '内容',
fileName: '文件名', fileName: '文件名',