mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/mihomo-party-org/clash-party.git
synced 2026-09-20 08:03:39 +08:00
fix: apply Mihomo settings changes to running core, close #1874
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
- 重构简化连接页
|
||||
- 优化软件启动和退出速度
|
||||
|
||||
## 修复 (Fix)
|
||||
|
||||
- 修复修改 Mihomo 设置(如日志等级、端口等)后未应用到运行中内核的问题
|
||||
|
||||
# 1.9.5
|
||||
|
||||
## 新功能 (Feat)
|
||||
|
||||
@@ -3,7 +3,7 @@ import { existsSync } from 'fs'
|
||||
import { controledMihomoConfigPath } from '../utils/dirs'
|
||||
import { parse, stringify } from '../utils/yaml'
|
||||
import { generateProfile } from '../core/factory'
|
||||
import { patchMihomoConfig } from '../core/mihomoApi'
|
||||
import { patchMihomoConfig, startMihomoLogs } from '../core/mihomoApi'
|
||||
import { defaultControledMihomoConfig } from '../utils/template'
|
||||
import { deepMerge } from '../utils/merge'
|
||||
import { createLogger } from '../utils/logger'
|
||||
@@ -114,6 +114,15 @@ export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>):
|
||||
error
|
||||
)
|
||||
}
|
||||
|
||||
// log-level 改变时重连日志 WebSocket,使新等级立刻生效
|
||||
if (patch['log-level']) {
|
||||
try {
|
||||
await startMihomoLogs()
|
||||
} catch (error) {
|
||||
controledMihomoLogger.warn('Failed to restart log stream after log-level change', error)
|
||||
}
|
||||
}
|
||||
})
|
||||
await controledMihomoWriteQueue
|
||||
}
|
||||
|
||||
@@ -320,6 +320,15 @@ const Mihomo: React.FC = () => {
|
||||
|
||||
const onChangeNeedRestart = async (patch: Partial<IMihomoConfig>): Promise<void> => {
|
||||
await patchControledMihomoConfig(patch)
|
||||
try {
|
||||
if (appConfig?.useHotReloadProfile) {
|
||||
await mihomoHotReloadConfig()
|
||||
} else {
|
||||
await restartCore()
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Apply config change failed:', e)
|
||||
}
|
||||
}
|
||||
|
||||
const handleConfigChangeWithRestart = async (key: string, value: unknown) => {
|
||||
|
||||
Reference in New Issue
Block a user