MCPcopy Create free account
hub / github.com/ZToolsCenter/ZTools / updateEngine

Method updateEngine

src/main/api/renderer/webSearch.ts:145–166  ·  view source on GitHub ↗

* 更新搜索引擎

(
    engine: WebSearchEngine
  )

Source from the content-addressed store, hash-verified

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 * 删除搜索引擎

Callers 2

setupIPCMethod · 0.95
setupIPCMethod · 0.80

Calls 4

getAllEnginesMethod · 0.95
notifyCommandsChangedMethod · 0.95
dbPutMethod · 0.45

Tested by

no test coverage detected