fix: before-quit uses HTTP shutdown, no kill
This commit is contained in:
1 parent
302472d881
commit
9f36b37485
1 file changed
+7
-2
+7
-2
@@ -21,7 +21,7 @@ function updateMenu() {
|
|||||||
{ label: '启动服务', enabled: !isRunning, click: startBackend },
|
{ label: '启动服务', enabled: !isRunning, click: startBackend },
|
||||||
{ label: '停止服务', enabled: isRunning, click: () => stopBackend() },
|
{ label: '停止服务', enabled: isRunning, click: () => stopBackend() },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ label: '退出', click: () => { killBackend(); app.quit() } },
|
{ label: '退出', click: () => { shutdownBackend(); app.quit() } },
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +52,11 @@ function killBackend() {
|
|||||||
updateMenu()
|
updateMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shutdownBackend() {
|
||||||
|
if (!backend) return
|
||||||
|
http.get('http://localhost:3000/api/shutdown').on('error', () => {})
|
||||||
|
}
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
tray = new Tray(ICON.resize({ width: 16, height: 16 }))
|
tray = new Tray(ICON.resize({ width: 16, height: 16 }))
|
||||||
tray.setToolTip('质量追溯系统')
|
tray.setToolTip('质量追溯系统')
|
||||||
@@ -60,4 +65,4 @@ app.whenReady().then(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
app.on('window-all-closed', () => {})
|
app.on('window-all-closed', () => {})
|
||||||
app.on('before-quit', () => killBackend())
|
app.on('before-quit', () => shutdownBackend())
|
||||||
Reference in new issue
Block a user