修复 API配置初始化时配置名称和认证方式显示为空的问题

- 修复 list-api-profiles 返回空数组导致配置名称显示为空
- 确保 loadSettings 加载时 API 相关字段有默认值
- 更新 package.json 项目描述和作者信息
This commit is contained in:
yuantao
2026-04-16 14:27:27 +08:00
parent e7f15d32ca
commit 67ab48b399
3 changed files with 28 additions and 6 deletions

View File

@@ -318,8 +318,13 @@ const inputDialogValue = ref('')
const loadApiProfiles = async () => {
const result = await window.electronAPI.listApiProfiles()
if (result.success) {
apiProfiles.value = result.profiles
currentApiProfile.value = result.currentProfile
// 确保至少有 default 配置
if (!result.profiles || result.profiles.length === 0) {
apiProfiles.value = [{ name: 'default', isDefault: true }]
} else {
apiProfiles.value = result.profiles
}
currentApiProfile.value = result.currentProfile || 'default'
}
}
@@ -397,6 +402,15 @@ const loadSettings = async () => {
const data = JSON.parse(JSON.stringify(result.data))
if (!data.checkpointing) data.checkpointing = { enabled: true }
if (!data.mcpServers) data.mcpServers = {}
// 确保 API 相关字段有默认值
if (data.selectedAuthType === undefined) data.selectedAuthType = 'iflow'
if (data.apiKey === undefined) data.apiKey = ''
if (data.baseUrl === undefined) data.baseUrl = ''
if (data.modelName === undefined) data.modelName = ''
if (data.searchApiKey === undefined) data.searchApiKey = ''
if (data.cna === undefined) data.cna = ''
if (!data.apiProfiles) data.apiProfiles = { default: {} }
if (!data.currentApiProfile) data.currentApiProfile = 'default'
settings.value = data
originalSettings.value = JSON.parse(JSON.stringify(data))
modified.value = false