web/src/app/infra/http/README.md
HTTP Client 已经重构为更清晰的架构,将通用方法与业务逻辑分离,并为不同的服务创建了独立的客户端。
// 使用后端客户端
import { backendClient } from '@/app/infra/http';
// 获取模型列表
const models = await backendClient.getProviderLLMModels();
// 使用云服务客户端(异步方式,确保 URL 已初始化)
import { getCloudServiceClient } from '@/app/infra/http';
const cloudClient = await getCloudServiceClient();
const marketPlugins = await cloudClient.getMarketPlugins(1, 10, 'search term');
// 使用云服务客户端(同步方式,可能使用默认 URL)
import { cloudServiceClient } from '@/app/infra/http';
const marketPlugins = await cloudServiceClient.getMarketPlugins(
1,
10,
'search term',
);
// 旧的用法仍然可以工作
import { httpClient, spaceClient } from '@/app/infra/http/HttpClient';
// httpClient 现在指向 backendClient
const models = await httpClient.getProviderLLMModels();
// spaceClient 现在指向 cloudServiceClient
const marketPlugins = await spaceClient.getMarketPlugins(1, 10, 'search term');
清晰的职责分离
自动初始化
类型安全
@/app/infra/entities/api 导入向后兼容