🐛 修复退出后frp仍在运行的BUG
This commit is contained in:
parent
f5df6bb87f
commit
4c12c800c5
@ -161,15 +161,17 @@ export const reloadFrpcProcess = () => {
|
|||||||
/**
|
/**
|
||||||
* 停止frpc子进程
|
* 停止frpc子进程
|
||||||
*/
|
*/
|
||||||
export const stopFrpcProcess = () => {
|
export const stopFrpcProcess = (callback?:() => void) => {
|
||||||
if (frpcProcess) {
|
if (frpcProcess) {
|
||||||
treeKill(frpcProcess.pid, (error: Error) => {
|
treeKill(frpcProcess.pid, (error: Error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log("关闭失败", frpcProcess.pid, error)
|
console.log("关闭失败", frpcProcess.pid, error)
|
||||||
} else {
|
} else {
|
||||||
|
console.log('关闭成功')
|
||||||
frpcProcess = null
|
frpcProcess = null
|
||||||
clearInterval(frpcStatusListener)
|
clearInterval(frpcStatusListener)
|
||||||
}
|
}
|
||||||
|
callback()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,9 @@ export const createTray = () => {
|
|||||||
label: '退出',
|
label: '退出',
|
||||||
click: () => {
|
click: () => {
|
||||||
isQuiting = true;
|
isQuiting = true;
|
||||||
app.quit();
|
stopFrpcProcess(() => {
|
||||||
|
app.quit();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@ -143,8 +145,11 @@ app.whenReady().then(() => {
|
|||||||
|
|
||||||
app.on("window-all-closed", () => {
|
app.on("window-all-closed", () => {
|
||||||
win = null;
|
win = null;
|
||||||
if (process.platform !== "darwin") app.quit();
|
if (process.platform !== "darwin") {
|
||||||
stopFrpcProcess()
|
stopFrpcProcess(() => {
|
||||||
|
app.quit();
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on("second-instance", () => {
|
app.on("second-instance", () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user