fix(ai): 优化API密钥验证逻辑,支持本地服务无密钥访问

- 修改 AIService 中 API 密钥验证逻辑,允许 Ollama 本地服务跳过密钥检查
- 更新所有 AI 提供商实例化时的类型断言,使用非空断言操作符(!)确保类型安全
- 完善 AISummarySettings 中连接测试逻辑,区分 Ollama 和 Custom 服务的验证需求
- 为 Custom 服务添加 baseURL 必填验证,提升配置完整性检查
- 升级版本至 2.1.4
- 改进本地 AI 服务和自定义服务的使用体验,降低配置门槛
This commit is contained in:
ILoveBingLu
2026-01-26 19:14:04 +08:00
parent 36c07295f1
commit 92fbcdabae
3 changed files with 22 additions and 14 deletions
+8 -1
View File
@@ -242,11 +242,18 @@ function AISummarySettings({
}
const handleTestConnection = async () => {
if (!apiKey) {
// Ollama 本地服务不需要 API 密钥
if (provider !== 'ollama' && !apiKey) {
showMessage('请先输入 API 密钥', false)
return
}
// Custom 服务必须配置 baseURL
if (provider === 'custom' && !baseURL) {
showMessage('请先配置服务地址', false)
return
}
setIsTesting(true)
try {