fix(settings): auto-save after deleting a model

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 11:49:40 +08:00
parent 977ef34aad
commit e9ce0235fd

View File

@@ -112,7 +112,7 @@ function addModel(type: string) {
}
// 删除模型
function removeModel(type: string, index: number) {
async function removeModel(type: string, index: number) {
// embedding/rerank 为知识库必填,至少保留 1 个
if ((type === 'embedding' || type === 'rerank') &&
llmConfig.value[type as keyof LLMConfig]!.length <= 1) {
@@ -122,6 +122,15 @@ function removeModel(type: string, index: number) {
llmConfig.value[type as keyof LLMConfig]!.splice(index, 1)
expandedRow.value = null
editingSnapshot.value = null
// 自动保存到后端
try {
await settingsApi.updateLLM(llmConfig.value)
originalLlmConfig.value = JSON.parse(JSON.stringify(llmConfig.value))
showToast('删除成功')
} catch (e: unknown) {
const msg = (e as { response?: { data?: { detail?: string } } })?.response?.data?.detail || '删除失败'
showToast(msg, 'error')
}
}
// 行标识