mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
fix alert blocking process
This commit is contained in:
parent
5b7958f2c7
commit
0ee6e144ed
@ -1,4 +1,4 @@
|
||||
import { app, ipcMain, safeStorage } from 'electron'
|
||||
import { app, dialog, ipcMain, safeStorage } from 'electron'
|
||||
import {
|
||||
mihomoChangeProxy,
|
||||
mihomoCloseAllConnections,
|
||||
@ -141,5 +141,8 @@ export function registerIpcMainHandlers(): void {
|
||||
ipcMain.handle('webdavBackup', ipcErrorWrapper(webdavBackup))
|
||||
ipcMain.handle('webdavRestore', (_e, filename) => ipcErrorWrapper(webdavRestore)(filename))
|
||||
ipcMain.handle('listWebdavBackups', ipcErrorWrapper(listWebdavBackups))
|
||||
ipcMain.handle('alert', (_e, msg) => {
|
||||
dialog.showErrorBox('Mihomo Party', msg)
|
||||
})
|
||||
ipcMain.handle('quitApp', () => app.quit())
|
||||
}
|
||||
|
||||
@ -46,9 +46,13 @@ const EditFileModal: React.FC<Props> = (props) => {
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={async () => {
|
||||
await setOverride(id, language === 'javascript' ? 'js' : 'yaml', currData)
|
||||
await restartCore()
|
||||
onClose()
|
||||
try {
|
||||
await setOverride(id, language === 'javascript' ? 'js' : 'yaml', currData)
|
||||
await restartCore()
|
||||
onClose()
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
}
|
||||
}}
|
||||
>
|
||||
确认
|
||||
|
||||
@ -27,9 +27,13 @@ const EditInfoModal: React.FC<Props> = (props) => {
|
||||
const [values, setValues] = useState(item)
|
||||
|
||||
const onSave = async (): Promise<void> => {
|
||||
await updateProfileItem(values)
|
||||
await restartCore()
|
||||
onClose()
|
||||
try {
|
||||
await updateProfileItem(values)
|
||||
await restartCore()
|
||||
onClose()
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -268,3 +268,10 @@ export async function listWebdavBackups(): Promise<string[]> {
|
||||
export async function quitApp(): Promise<void> {
|
||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('quitApp'))
|
||||
}
|
||||
|
||||
async function alert<T>(msg: T): Promise<void> {
|
||||
const msgStr = typeof msg === 'string' ? msg : JSON.stringify(msg)
|
||||
return await window.electron.ipcRenderer.invoke('alert', msgStr)
|
||||
}
|
||||
|
||||
window.alert = alert
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user