mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
fix core upgrade
This commit is contained in:
parent
90f5db2b7c
commit
06dc72a88a
|
@ -5,7 +5,9 @@
|
|||
### New Features
|
||||
|
||||
- MacOS 支持自动设置系统DNS
|
||||
- 调整UI细节
|
||||
|
||||
### Performance Improvements
|
||||
### Bug Fixes
|
||||
|
||||
- 修复更新内核后内核无法正常关闭的问题
|
||||
- 优化规则/代理页面性能
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
"@mihomo-party/sysproxy": "^2.0.1",
|
||||
"adm-zip": "^0.5.15",
|
||||
"axios": "^1.7.5",
|
||||
"chokidar": "^3.6.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"webdav": "^5.7.1",
|
||||
"ws": "^8.18.0",
|
||||
|
|
|
@ -23,6 +23,9 @@ importers:
|
|||
axios:
|
||||
specifier: ^1.7.5
|
||||
version: 1.7.5
|
||||
chokidar:
|
||||
specifier: ^3.6.0
|
||||
version: 3.6.0
|
||||
dayjs:
|
||||
specifier: ^1.11.13
|
||||
version: 1.11.13
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { ChildProcess, exec, execFile, spawn } from 'child_process'
|
||||
import {
|
||||
logPath,
|
||||
mihomoCoreDir,
|
||||
mihomoCorePath,
|
||||
mihomoTestDir,
|
||||
mihomoWorkConfigPath,
|
||||
|
@ -15,9 +16,21 @@ import {
|
|||
} from '../config'
|
||||
import { dialog, safeStorage } from 'electron'
|
||||
import { pauseWebsockets, startMihomoTraffic } from './mihomoApi'
|
||||
import chokidar from 'chokidar'
|
||||
import { writeFile } from 'fs/promises'
|
||||
import { promisify } from 'util'
|
||||
import { mainWindow } from '..'
|
||||
import path from 'path'
|
||||
|
||||
chokidar
|
||||
.watch(path.join(mihomoCoreDir(), 'meta-update'))
|
||||
.on('all', (event, path) => {
|
||||
console.log(event, path)
|
||||
})
|
||||
.on('unlinkDir', async () => {
|
||||
await stopCore(true)
|
||||
await startCore()
|
||||
})
|
||||
|
||||
let child: ChildProcess
|
||||
let retry = 10
|
||||
|
@ -48,10 +61,6 @@ export async function startCore(): Promise<void> {
|
|||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
child.stdout?.on('data', async (data) => {
|
||||
if (data.toString().includes('updater: finished')) {
|
||||
await stopCore()
|
||||
await startCore()
|
||||
}
|
||||
if (data.toString().includes('configure tun interface: operation not permitted')) {
|
||||
await patchControledMihomoConfig({ tun: { enable: false } })
|
||||
mainWindow?.webContents.send('controledMihomoConfigUpdated')
|
||||
|
@ -78,9 +87,11 @@ export async function startCore(): Promise<void> {
|
|||
})
|
||||
}
|
||||
|
||||
export async function stopCore(): Promise<void> {
|
||||
export async function stopCore(force = false): Promise<void> {
|
||||
try {
|
||||
await recoverDNS()
|
||||
if (!force) {
|
||||
await recoverDNS()
|
||||
}
|
||||
} catch (error) {
|
||||
// todo
|
||||
}
|
||||
|
|
|
@ -77,7 +77,11 @@ const Mihomo: React.FC = () => {
|
|||
PubSub.publish('mihomo-core-changed')
|
||||
}, 2000)
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
if (typeof e === 'string' && e.includes('already using latest version')) {
|
||||
new Notification('已经是最新版本')
|
||||
} else {
|
||||
alert(e)
|
||||
}
|
||||
} finally {
|
||||
setUpgrading(false)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user