Fundamental_Analysis/frontend/src/app/reports/page.tsx
Lv, Qi a1e4b265ba feat(config): Implement database-centric LLM provider architecture
本次提交完成了一次全面的架构重构,实现了以数据库为中心的、支持多供应商的LLM配置体系。

**核心变更**:
1.  **数据库驱动配置**: 废弃了所有基于本地文件的配置方案 (`analysis-config.json`),将LLM Provider和分析模块的配置作为结构化数据存入数据库的`system_config`表中,由`data-persistence-service`统一管理。
2.  **Schema-in-Code**: 在`common-contracts`中定义了所有配置的Rust Structs,作为整个系统的“单一事实源”,确保了端到端的类型安全。
3.  **服务职责重构**:
    *   `data-persistence-service`吸收了配置管理功能,成为配置的“守门人”。
    *   `config-service-rs`服务已被彻底移除。
    *   `report-generator-service`重构为可以为每个任务动态创建使用不同Provider配置的LLM客户端。
4.  **前端功能增强**:
    *   新增了独立的`/llm-config`页面,用于对LLM Providers及其可用模型进行完整的CRUD管理,并支持模型自动发现。
    *   重构了旧的`/config`页面,为分析模块提供了级联选择器来精确指定所需的Provider和Model。

此次重构极大地提升了系统的灵活性和可扩展性,完全对齐了“配置即数据”的现代化设计原则。
2025-11-17 04:41:36 +08:00

60 lines
2.4 KiB
TypeScript

import Link from 'next/link'
import { headers } from 'next/headers'
async function fetchReports(baseUrl: string) {
const url = `${baseUrl}/api/reports?limit=50`
const resp = await fetch(url, { cache: 'no-store' })
if (!resp.ok) {
return { items: [], total: 0 }
}
return resp.json() as Promise<{ items: Array<{ id: string; symbol: string; createdAt: string; content?: any }>; total: number }>
}
export default async function ReportsPage() {
const h = await headers()
const host = h.get('x-forwarded-host') || h.get('host') || 'localhost:3000'
const proto = h.get('x-forwarded-proto') || 'http'
const base = process.env.FRONTEND_INTERNAL_URL || process.env.NEXT_PUBLIC_BASE_URL || `${proto}://${host}`
const { items, total } = await fetchReports(base)
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<h1 className="text-2xl font-semibold"></h1>
<div className="text-sm text-muted-foreground"> {total} </div>
</div>
{items.length === 0 ? (
<p className="text-sm text-muted-foreground"></p>
) : (
<div className="overflow-x-auto border rounded-md">
<table className="min-w-full text-sm">
<thead>
<tr className="bg-muted">
<th className="text-left p-3"></th>
<th className="text-left p-3"></th>
<th className="text-left p-3"></th>
<th className="text-right p-3"></th>
</tr>
</thead>
<tbody>
{items.map((r) => {
const name = (r as any)?.content?.financials?.name || (r as any)?.content?.company_name || ''
return (
<tr key={r.id} className="border-t hover:bg-muted/50">
<td className="p-3 font-medium">{r.symbol}</td>
<td className="p-3">{name || <span className="text-muted-foreground">-</span>}</td>
<td className="p-3">{new Date(r.createdAt).toLocaleString()}</td>
<td className="p-3 text-right">
<Link href={`/reports/${r.id}`} className="text-primary hover:underline"></Link>
</td>
</tr>
)
})}
</tbody>
</table>
</div>
)}
</div>
)
}