mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
cleanup on shutdown
This commit is contained in:
parent
1f2eee133b
commit
9f0a18ecce
|
@ -2,6 +2,7 @@
|
|||
|
||||
- Windows 允许添加 `noadmin` 参数以普通权限启动程序
|
||||
- 支持在 Windows 任务栏显示网速信息
|
||||
- 支持在关机前自动关闭系统代理
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||
import { registerIpcMainHandlers } from './utils/ipc'
|
||||
import windowStateKeeper from 'electron-window-state'
|
||||
import { app, shell, BrowserWindow, Menu, dialog, Notification } from 'electron'
|
||||
import { app, shell, BrowserWindow, Menu, dialog, Notification, powerMonitor } from 'electron'
|
||||
import { addProfileItem, getAppConfig } from './config'
|
||||
import { quitWithoutCore, startCore, stopCore } from './core/manager'
|
||||
import { triggerSysProxy } from './sys/sysproxy'
|
||||
|
@ -96,9 +96,17 @@ app.on('window-all-closed', (e) => {
|
|||
// }
|
||||
})
|
||||
|
||||
app.on('before-quit', async () => {
|
||||
await stopCore()
|
||||
app.on('before-quit', async (e) => {
|
||||
e.preventDefault()
|
||||
triggerSysProxy(false)
|
||||
await stopCore()
|
||||
app.exit()
|
||||
})
|
||||
|
||||
powerMonitor.on('shutdown', async (e) => {
|
||||
e.preventDefault()
|
||||
triggerSysProxy(false)
|
||||
await stopCore()
|
||||
app.exit()
|
||||
})
|
||||
|
||||
|
@ -239,6 +247,11 @@ export async function createWindow(): Promise<void> {
|
|||
}
|
||||
})
|
||||
|
||||
mainWindow.on('session-end', async () => {
|
||||
triggerSysProxy(false)
|
||||
await stopCore()
|
||||
})
|
||||
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url)
|
||||
return { action: 'deny' }
|
||||
|
|
Loading…
Reference in New Issue
Block a user