* 删除 AI 模型
(modelId: string)
| 159 | * 删除 AI 模型 |
| 160 | */ |
| 161 | public deleteModel(modelId: string): { success: boolean; error?: string } { |
| 162 | const models = this.getAllModels() |
| 163 | |
| 164 | // 查找要删除的模型 |
| 165 | const index = models.findIndex((m: AiModel) => m.id === modelId) |
| 166 | if (index === -1) { |
| 167 | return { success: false, error: '未找到该模型' } |
| 168 | } |
| 169 | |
| 170 | // 删除模型 |
| 171 | models.splice(index, 1) |
| 172 | |
| 173 | // 保存到数据库(databaseAPI 会自动处理 _rev) |
| 174 | databaseAPI.dbPut(this.DB_KEY, models) |
| 175 | |
| 176 | return { success: true } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | // 导出单例 |
no test coverage detected