You've already forked iFlow-Settings-Editor-GUI
修复 API配置初始化时配置名称和认证方式显示为空的问题
- 修复 list-api-profiles 返回空数组导致配置名称显示为空 - 确保 loadSettings 加载时 API 相关字段有默认值 - 更新 package.json 项目描述和作者信息
This commit is contained in:
9
main.js
9
main.js
@@ -112,10 +112,15 @@ ipcMain.handle('list-api-profiles', async () => {
|
|||||||
try {
|
try {
|
||||||
const settings = readSettings()
|
const settings = readSettings()
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
return { success: false, error: '配置文件不存在', profiles: [], currentProfile: '' }
|
return { success: true, profiles: [{ name: 'default', isDefault: true }], currentProfile: 'default' }
|
||||||
}
|
}
|
||||||
|
|
||||||
const profiles = settings.apiProfiles || {}
|
const profiles = settings.apiProfiles || {}
|
||||||
|
// 确保至少有 default 配置
|
||||||
|
if (Object.keys(profiles).length === 0) {
|
||||||
|
profiles.default = {}
|
||||||
|
}
|
||||||
|
|
||||||
const profileList = Object.keys(profiles).map(name => ({
|
const profileList = Object.keys(profiles).map(name => ({
|
||||||
name,
|
name,
|
||||||
isDefault: name === 'default'
|
isDefault: name === 'default'
|
||||||
@@ -127,7 +132,7 @@ ipcMain.handle('list-api-profiles', async () => {
|
|||||||
currentProfile: settings.currentApiProfile || 'default'
|
currentProfile: settings.currentApiProfile || 'default'
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { success: false, error: error.message, profiles: [], currentProfile: '' }
|
return { success: false, error: error.message, profiles: [{ name: 'default', isDefault: true }], currentProfile: 'default' }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "iflow-settings-editor",
|
"name": "iflow-settings-editor",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "iFlow Settings Editor - Vue 3 + Electron",
|
"description": "一个用于编辑 iFlow CLI 配置文件的桌面应用程序。",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"author": "iFlow",
|
"author": "上海潘哆呐科技有限公司",
|
||||||
|
"repository": {
|
||||||
|
"url": "https://git.pandorastudio.cn/product/iFlow-Settings-Editor-GUI.git"
|
||||||
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
18
src/App.vue
18
src/App.vue
@@ -318,8 +318,13 @@ const inputDialogValue = ref('')
|
|||||||
const loadApiProfiles = async () => {
|
const loadApiProfiles = async () => {
|
||||||
const result = await window.electronAPI.listApiProfiles()
|
const result = await window.electronAPI.listApiProfiles()
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
apiProfiles.value = result.profiles
|
// 确保至少有 default 配置
|
||||||
currentApiProfile.value = result.currentProfile
|
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))
|
const data = JSON.parse(JSON.stringify(result.data))
|
||||||
if (!data.checkpointing) data.checkpointing = { enabled: true }
|
if (!data.checkpointing) data.checkpointing = { enabled: true }
|
||||||
if (!data.mcpServers) data.mcpServers = {}
|
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
|
settings.value = data
|
||||||
originalSettings.value = JSON.parse(JSON.stringify(data))
|
originalSettings.value = JSON.parse(JSON.stringify(data))
|
||||||
modified.value = false
|
modified.value = false
|
||||||
|
|||||||
Reference in New Issue
Block a user