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