* 自动保存配置
()
| 166 | * 自动保存配置 |
| 167 | */ |
| 168 | async function autoSaveConfig() { |
| 169 | try { |
| 170 | const config: Partial<Config> = { |
| 171 | text_generation: { |
| 172 | active_provider: textConfig.value.active_provider, |
| 173 | providers: textConfig.value.providers |
| 174 | }, |
| 175 | image_generation: imageConfig.value |
| 176 | } |
| 177 | |
| 178 | const result = await updateConfig(config) |
| 179 | if (result.success) { |
| 180 | // 重新加载配置以获取最新的脱敏 API Key |
| 181 | await loadConfig() |
| 182 | setSuccess(result.message || '配置已保存') |
| 183 | } |
| 184 | } catch (e) { |
| 185 | console.error('自动保存失败:', e) |
| 186 | setError(e, '保存配置失败') |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | function setSuccess(message: string) { |
| 191 | feedback.value = { type: 'success', message } |
no test coverage detected