diff --git a/main.js b/main.js index 91fbdd5..d889c83 100644 --- a/main.js +++ b/main.js @@ -112,10 +112,15 @@ ipcMain.handle('list-api-profiles', async () => { try { const settings = readSettings() if (!settings) { - return { success: false, error: '配置文件不存在', profiles: [], currentProfile: '' } + return { success: true, profiles: [{ name: 'default', isDefault: true }], currentProfile: 'default' } } const profiles = settings.apiProfiles || {} + // 确保至少有 default 配置 + if (Object.keys(profiles).length === 0) { + profiles.default = {} + } + const profileList = Object.keys(profiles).map(name => ({ name, isDefault: name === 'default' @@ -127,7 +132,7 @@ ipcMain.handle('list-api-profiles', async () => { currentProfile: settings.currentApiProfile || 'default' } } catch (error) { - return { success: false, error: error.message, profiles: [], currentProfile: '' } + return { success: false, error: error.message, profiles: [{ name: 'default', isDefault: true }], currentProfile: 'default' } } }) diff --git a/package.json b/package.json index 83c2bc2..6728f4d 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,12 @@ { "name": "iflow-settings-editor", "version": "1.0.0", - "description": "iFlow Settings Editor - Vue 3 + Electron", + "description": "一个用于编辑 iFlow CLI 配置文件的桌面应用程序。", "main": "main.js", - "author": "iFlow", + "author": "上海潘哆呐科技有限公司", + "repository": { + "url": "https://git.pandorastudio.cn/product/iFlow-Settings-Editor-GUI.git" + }, "license": "MIT", "scripts": { "dev": "vite", diff --git a/src/App.vue b/src/App.vue index 8b40e96..0cbd3c8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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