From 4c12c800c5b690df07c082b20548884761bf52fe Mon Sep 17 00:00:00 2001 From: luckliu <8473136@qq.com> Date: Fri, 1 Dec 2023 16:55:29 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E9=80=80=E5=87=BA?= =?UTF-8?q?=E5=90=8Efrp=E4=BB=8D=E5=9C=A8=E8=BF=90=E8=A1=8C=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/api/frpc.ts | 4 +++- electron/main/index.ts | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/electron/api/frpc.ts b/electron/api/frpc.ts index 6994ec5..09cbbda 100644 --- a/electron/api/frpc.ts +++ b/electron/api/frpc.ts @@ -161,15 +161,17 @@ export const reloadFrpcProcess = () => { /** * 停止frpc子进程 */ -export const stopFrpcProcess = () => { +export const stopFrpcProcess = (callback?:() => void) => { if (frpcProcess) { treeKill(frpcProcess.pid, (error: Error) => { if (error) { console.log("关闭失败", frpcProcess.pid, error) } else { + console.log('关闭成功') frpcProcess = null clearInterval(frpcStatusListener) } + callback() }) } } diff --git a/electron/main/index.ts b/electron/main/index.ts index 4eee4a8..3a59204 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -120,7 +120,9 @@ export const createTray = () => { label: '退出', click: () => { isQuiting = true; - app.quit(); + stopFrpcProcess(() => { + app.quit(); + }) } } ]; @@ -143,8 +145,11 @@ app.whenReady().then(() => { app.on("window-all-closed", () => { win = null; - if (process.platform !== "darwin") app.quit(); - stopFrpcProcess() + if (process.platform !== "darwin") { + stopFrpcProcess(() => { + app.quit(); + }) + } }); app.on("second-instance", () => {