fix: 第3轮调试Bug修复 (P1: 弱随机+crypto/rand, Knowledge键对齐; P2: 简报created_at, CORS+安全头)

This commit is contained in:
2026-05-20 14:20:47 +08:00
parent 25d6eff7c3
commit 3adf0137cc
6 changed files with 349 additions and 16 deletions
+4 -3
View File
@@ -39,7 +39,8 @@ export interface SearchChunkResult {
/** 知识库列表响应 */
interface KBListResponse {
bases: KnowledgeBase[];
knowledge_bases: KnowledgeBase[];
total: number;
}
/** 文档列表响应 */
@@ -49,7 +50,7 @@ interface DocListResponse {
/** 搜索响应 */
interface SearchResponse {
results: SearchChunkResult[];
chunks: SearchChunkResult[];
total: number;
query: string;
}
@@ -70,7 +71,7 @@ export async function createKB(name: string, description?: string): Promise<Know
export async function listKBs(): Promise<KnowledgeBase[]> {
const res = await request<KBListResponse>(`/knowledge/bases`);
if (res.error) throw new Error(res.error);
return res.data?.bases || [];
return res.data?.knowledge_bases || [];
}
/** 获取知识库 */
@@ -178,7 +178,7 @@ export function KnowledgePanel({ onClose }: KnowledgePanelProps) {
setSearchErr('');
try {
const res = await searchKnowledge(searchQuery.trim());
setSearchResults(res.results);
setSearchResults(res.chunks);
setSearchTotal(res.total);
} catch (e: any) {
setSearchErr(e.message || '搜索失败');