refactor(config): 移除环境变量依赖,统一使用 Provider 配置系统

- 移除 .env.example 文件
- 简化 resolveApiKey 函数,只从配置文件读取 API Key
- 重构 loadConfig/loadVisionConfig/loadSummaryConfig 使用 ProviderRegistry
- 更新测试以 mock Provider 系统
This commit is contained in:
2025-12-14 21:29:36 +08:00
parent c9d0cbce5b
commit 9e011476c8
6 changed files with 143 additions and 451 deletions
+2 -15
View File
@@ -73,22 +73,9 @@ export async function saveProvidersConfig(
/**
* 获取提供商的 API Key
* 优先从环境变量获取,其次从配置获取
* 从配置文件获取
*/
export function resolveApiKey(config?: ProviderConfig, envVar?: string): string | undefined {
// 优先使用配置中指定的环境变量
if (config?.apiKeyEnvVar) {
const key = process.env[config.apiKeyEnvVar];
if (key) return key;
}
// 其次使用默认环境变量
if (envVar) {
const key = process.env[envVar];
if (key) return key;
}
// 最后使用直接配置的 apiKey
export function resolveApiKey(config?: ProviderConfig): string | undefined {
return config?.apiKey;
}