You've already forked iFlow-Settings-Editor-GUI
修复 API 配置编辑功能,确保编辑按钮显示正确的配置数据
This commit is contained in:
61
src/App.vue
61
src/App.vue
@@ -152,9 +152,10 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="profile-actions" v-if="profile.name !== 'default'">
|
||||
<button class="action-btn" @click.stop="openApiEditDialog" title="编辑">
|
||||
<button class="action-btn" @click.stop="openApiEditDialog(profile.name)" title="编辑">
|
||||
<Edit size="14" />
|
||||
</button> <button class="action-btn" @click.stop="duplicateApiProfile(profile.name)" title="复制">
|
||||
</button>
|
||||
<button class="action-btn" @click.stop="duplicateApiProfile(profile.name)" title="复制">
|
||||
<Copy size="14" />
|
||||
</button> <button class="action-btn action-btn-danger" @click.stop="deleteApiProfile(profile.name)" title="删除">
|
||||
<Delete size="14" />
|
||||
@@ -465,6 +466,7 @@ const editingServerData = ref({
|
||||
env: ''
|
||||
})
|
||||
const showApiEditDialog = ref(false)
|
||||
const editingApiProfileName = ref('')
|
||||
const editingApiData = ref({
|
||||
selectedAuthType: 'iflow',
|
||||
apiKey: '',
|
||||
@@ -811,27 +813,20 @@ const duplicateApiProfile = async (name) => {
|
||||
|
||||
|
||||
// Open API edit dialog
|
||||
|
||||
const openApiEditDialog = () => {
|
||||
|
||||
const openApiEditDialog = (profileName) => {
|
||||
// 保存正在编辑的配置名称
|
||||
editingApiProfileName.value = profileName
|
||||
// 从 apiProfiles 中加载指定配置的数据
|
||||
const profile = settings.value.apiProfiles && settings.value.apiProfiles[profileName]
|
||||
editingApiData.value = {
|
||||
|
||||
selectedAuthType: settings.value.selectedAuthType || 'iflow',
|
||||
|
||||
apiKey: settings.value.apiKey || '',
|
||||
|
||||
baseUrl: settings.value.baseUrl || '',
|
||||
|
||||
modelName: settings.value.modelName || '',
|
||||
|
||||
searchApiKey: settings.value.searchApiKey || '',
|
||||
|
||||
cna: settings.value.cna || ''
|
||||
|
||||
selectedAuthType: profile ? profile.selectedAuthType : settings.value.selectedAuthType || 'iflow',
|
||||
apiKey: profile ? profile.apiKey : settings.value.apiKey || '',
|
||||
baseUrl: profile ? profile.baseUrl : settings.value.baseUrl || '',
|
||||
modelName: profile ? profile.modelName : settings.value.modelName || '',
|
||||
searchApiKey: profile ? profile.searchApiKey : settings.value.searchApiKey || '',
|
||||
cna: profile ? profile.cna : settings.value.cna || ''
|
||||
}
|
||||
|
||||
showApiEditDialog.value = true
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -847,23 +842,25 @@ const closeApiEditDialog = () => {
|
||||
|
||||
|
||||
// Save API edit
|
||||
|
||||
const saveApiEdit = () => {
|
||||
if (!settings.value.apiProfiles) {
|
||||
settings.value.apiProfiles = {}
|
||||
}
|
||||
|
||||
settings.value.selectedAuthType = editingApiData.value.selectedAuthType
|
||||
// 确保配置对象存在
|
||||
if (!settings.value.apiProfiles[editingApiProfileName.value]) {
|
||||
settings.value.apiProfiles[editingApiProfileName.value] = {}
|
||||
}
|
||||
|
||||
settings.value.apiKey = editingApiData.value.apiKey
|
||||
|
||||
settings.value.baseUrl = editingApiData.value.baseUrl
|
||||
|
||||
settings.value.modelName = editingApiData.value.modelName
|
||||
|
||||
settings.value.searchApiKey = editingApiData.value.searchApiKey
|
||||
|
||||
settings.value.cna = editingApiData.value.cna
|
||||
// 保存到指定的配置
|
||||
settings.value.apiProfiles[editingApiProfileName.value].selectedAuthType = editingApiData.value.selectedAuthType
|
||||
settings.value.apiProfiles[editingApiProfileName.value].apiKey = editingApiData.value.apiKey
|
||||
settings.value.apiProfiles[editingApiProfileName.value].baseUrl = editingApiData.value.baseUrl
|
||||
settings.value.apiProfiles[editingApiProfileName.value].modelName = editingApiData.value.modelName
|
||||
settings.value.apiProfiles[editingApiProfileName.value].searchApiKey = editingApiData.value.searchApiKey
|
||||
settings.value.apiProfiles[editingApiProfileName.value].cna = editingApiData.value.cna
|
||||
|
||||
showApiEditDialog.value = false
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user