修复缺失的 checkStatus IPC处理器
- 添加 checkStatus IPC handler 到主进程 - 实现基础的 API 连通性检查 - 修复 preload API 与主进程不匹配的问题
This commit is contained in:
@@ -114,4 +114,18 @@ ipcMain.handle('selectConfigFile', async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result.filePaths[0]
|
return result.filePaths[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
ipcMain.handle('checkStatus', async (_, provider: Provider) => {
|
||||||
|
// 简单的连通性检查 - 向API地址发送HEAD请求
|
||||||
|
try {
|
||||||
|
const response = await fetch(provider.apiUrl, {
|
||||||
|
method: 'HEAD',
|
||||||
|
timeout: 5000
|
||||||
|
})
|
||||||
|
return response.ok
|
||||||
|
} catch (error) {
|
||||||
|
console.error('检查供应商状态失败:', error)
|
||||||
|
return false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user