From ea2a86fe304cee03681fc51dfdb17694cdf9b2f9 Mon Sep 17 00:00:00 2001 From: farion1231 Date: Wed, 6 Aug 2025 07:41:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=BA=E5=A4=B1=E7=9A=84?= =?UTF-8?q?=20checkStatus=20IPC=E5=A4=84=E7=90=86=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 checkStatus IPC handler 到主进程 - 实现基础的 API 连通性检查 - 修复 preload API 与主进程不匹配的问题 --- src/main/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/index.ts b/src/main/index.ts index 818d3cf..7b52288 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -114,4 +114,18 @@ ipcMain.handle('selectConfigFile', async () => { } 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 + } }) \ No newline at end of file