fix(frontend): 修复合并审阅发现的构建与契约问题

恢复 Vue TypeScript 生产构建,补齐可运行页面壳子,并修复文件树与 SSE 状态问题。

按 FastAPI Wire Contract 统一 Service DTO 映射,同时补充前端开发说明和问题修复复盘。
This commit is contained in:
2026-08-29 12:10:33 +08:00
parent c6c28e4ebe
commit 610fc77b0f
32 changed files with 1204 additions and 611 deletions
+19 -15
View File
@@ -1,25 +1,29 @@
import apiClient from './apiClient'
import type { IndexStatus } from '@/contracts'
import type { ApiIndexJob, ApiIndexStatus, IndexStatus } from '@/contracts'
export async function getIndexStatus(): Promise<IndexStatus> {
try {
return await apiClient.get('/api/index/status')
} catch {
return mockIndexStatus
function toIndexStatus(status: ApiIndexStatus): IndexStatus {
return {
status: status.status === 'idle' ? 'idle' : status.status === 'failed' ? 'error' : 'indexing',
pending_jobs: status.pending_jobs,
total_notes: 0,
total_blocks: 0,
fts_enabled: true,
vector_enabled: true,
last_indexed_at: status.last_completed_at ?? undefined,
error: status.error_message ?? undefined,
}
}
export async function rebuildIndex(scope: 'full' | 'fts' | 'vector' = 'full'): Promise<{ job_id: string }> {
return apiClient.post('/api/index/rebuild', { scope })
export async function getIndexStatus(): Promise<IndexStatus> {
return toIndexStatus(await apiClient.get<ApiIndexStatus>('/api/index/status'))
}
export async function getIndexJob(jobId: string): Promise<{
job_id: string
status: 'queued' | 'running' | 'completed' | 'failed'
progress: number
total: number
error?: string
}> {
export async function rebuildIndex(scope: 'full' | 'fts' | 'vector' = 'full'): Promise<ApiIndexJob> {
const apiScope = scope === 'full' ? 'all' : scope === 'fts' ? 'notes' : 'vectors'
return apiClient.post<ApiIndexJob>('/api/index/rebuild', { scope: apiScope })
}
export async function getIndexJob(jobId: string): Promise<ApiIndexJob> {
return apiClient.get(`/api/index/jobs/${jobId}`)
}