fix(frontend): 修复合并审阅发现的构建与契约问题
恢复 Vue TypeScript 生产构建,补齐可运行页面壳子,并修复文件树与 SSE 状态问题。 按 FastAPI Wire Contract 统一 Service DTO 映射,同时补充前端开发说明和问题修复复盘。
This commit is contained in:
@@ -1,15 +1,45 @@
|
||||
import apiClient from './apiClient'
|
||||
import type { SearchRequest, SearchResult } from '@/contracts'
|
||||
import type { ApiSearchResult, PageMeta, SearchRequest, SearchResult } from '@/contracts'
|
||||
|
||||
export async function search(request: SearchRequest): Promise<{
|
||||
results: SearchResult[]
|
||||
total: number
|
||||
mode: SearchRequest['mode']
|
||||
}> {
|
||||
return apiClient.post('/api/search', request)
|
||||
const response = await apiClient.post<{
|
||||
query: string
|
||||
mode: 'fts' | 'vector' | 'hybrid'
|
||||
items: ApiSearchResult[]
|
||||
page: PageMeta
|
||||
}>('/api/search', {
|
||||
query: request.query,
|
||||
mode: request.mode ?? 'hybrid',
|
||||
folders: request.folder ? [request.folder] : [],
|
||||
note_ids: request.note_id ? [request.note_id] : [],
|
||||
tags: request.tag ? [request.tag] : [],
|
||||
limit: request.limit ?? 20,
|
||||
offset: request.offset ?? 0,
|
||||
})
|
||||
return {
|
||||
results: response.items.map((item) => ({
|
||||
block_id: item.block_id,
|
||||
note_id: item.note_id,
|
||||
note_title: item.title,
|
||||
file_path: item.file_path,
|
||||
heading_path: item.heading_path.join(' / '),
|
||||
snippet: item.snippet ?? '',
|
||||
score: item.score,
|
||||
match_type: response.mode,
|
||||
})),
|
||||
total: response.page.total,
|
||||
mode: response.mode,
|
||||
}
|
||||
}
|
||||
|
||||
export async function searchMock(query: string, mode = 'hybrid' as const): Promise<{
|
||||
export async function searchMock(
|
||||
query: string,
|
||||
mode: 'fts' | 'vector' | 'hybrid' = 'hybrid'
|
||||
): Promise<{
|
||||
results: SearchResult[]
|
||||
total: number
|
||||
mode: 'fts' | 'vector' | 'hybrid'
|
||||
|
||||
Reference in New Issue
Block a user