* 更新搜索引擎
(
engine: WebSearchEngine
)
| 143 | * 更新搜索引擎 |
| 144 | */ |
| 145 | public async updateEngine( |
| 146 | engine: WebSearchEngine |
| 147 | ): Promise<{ success: boolean; error?: string }> { |
| 148 | const validated = this.validateAndNormalizeEngine(engine, true) |
| 149 | if (!validated.success) { |
| 150 | return { success: false, error: validated.error } |
| 151 | } |
| 152 | const normalizedEngine = validated.engine! |
| 153 | |
| 154 | const engines = this.getAllEngines() |
| 155 | const index = engines.findIndex((e) => e.id === normalizedEngine.id) |
| 156 | if (index === -1) { |
| 157 | return { success: false, error: '未找到该搜索引擎' } |
| 158 | } |
| 159 | |
| 160 | engines[index] = normalizedEngine |
| 161 | databaseAPI.dbPut(this.DB_KEY, engines) |
| 162 | |
| 163 | this.notifyCommandsChanged() |
| 164 | |
| 165 | return { success: true } |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * 删除搜索引擎 |
no test coverage detected