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