mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
restart core when enable tun
This commit is contained in:
parent
356e058a8a
commit
e3acf47c6d
@ -17,6 +17,7 @@ import { mainWindow, showMainWindow } from '..'
|
||||
import { app, clipboard, ipcMain, Menu, nativeImage, shell, Tray } from 'electron'
|
||||
import { dataDir, logDir, mihomoCoreDir, mihomoWorkDir } from '../utils/dirs'
|
||||
import { triggerSysProxy } from '../sys/sysproxy'
|
||||
import { restartCore } from '../core/manager'
|
||||
|
||||
export let tray: Tray | null = null
|
||||
|
||||
@ -154,8 +155,8 @@ const buildContextMenu = async (): Promise<Menu> => {
|
||||
} else {
|
||||
await patchControledMihomoConfig({ tun: { enable } })
|
||||
}
|
||||
await patchMihomoConfig({ tun: { enable } })
|
||||
mainWindow?.webContents.send('controledMihomoConfigUpdated')
|
||||
await restartCore()
|
||||
ipcMain.emit('updateTrayMenu')
|
||||
}
|
||||
},
|
||||
|
||||
@ -3,12 +3,7 @@ import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-c
|
||||
import BorderSwitch from '@renderer/components/base/border-swtich'
|
||||
import { TbDeviceIpadHorizontalBolt } from 'react-icons/tb'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import {
|
||||
encryptString,
|
||||
patchMihomoConfig,
|
||||
isEncryptionAvailable,
|
||||
restartCore
|
||||
} from '@renderer/utils/ipc'
|
||||
import { encryptString, isEncryptionAvailable, restartCore } from '@renderer/utils/ipc'
|
||||
import { useSortable } from '@dnd-kit/sortable'
|
||||
import { CSS } from '@dnd-kit/utilities'
|
||||
import { platform } from '@renderer/utils/init'
|
||||
@ -55,7 +50,7 @@ const TunSwitcher: React.FC = () => {
|
||||
} else {
|
||||
await patchControledMihomoConfig({ tun: { enable } })
|
||||
}
|
||||
await patchMihomoConfig({ tun: { enable } })
|
||||
await restartCore()
|
||||
window.electron.ipcRenderer.send('updateTrayMenu')
|
||||
}
|
||||
|
||||
@ -73,10 +68,14 @@ const TunSwitcher: React.FC = () => {
|
||||
<BasePasswordModal
|
||||
onCancel={() => setOpenPasswordModal(false)}
|
||||
onConfirm={async (password: string) => {
|
||||
const encrypted = await encryptString(password)
|
||||
await patchAppConfig({ encryptedPassword: encrypted })
|
||||
await restartCore()
|
||||
setOpenPasswordModal(false)
|
||||
try {
|
||||
const encrypted = await encryptString(password)
|
||||
await patchAppConfig({ encryptedPassword: encrypted })
|
||||
await restartCore()
|
||||
setOpenPasswordModal(false)
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user