diff --git a/changelog.md b/changelog.md index 9abcc0e..459cedc 100644 --- a/changelog.md +++ b/changelog.md @@ -5,3 +5,7 @@ ### New Features - 支持自动开启轻量模式 + +### Bug Fixes + +- 修复日志等级为静默时,无法正常启动的问题 diff --git a/src/main/core/factory.ts b/src/main/core/factory.ts index 0c28c8a..a7c1bde 100644 --- a/src/main/core/factory.ts +++ b/src/main/core/factory.ts @@ -21,6 +21,8 @@ export async function generateProfile(): Promise { const currentProfile = await overrideProfile(current, await getProfile(current)) const controledMihomoConfig = await getControledMihomoConfig() const profile = deepMerge(currentProfile, controledMihomoConfig) + // 确保可以拿到基础日志信息 + profile['log-level'] = 'info' runtimeConfig = profile runtimeConfigStr = yaml.stringify(profile) await writeFile(mihomoWorkConfigPath(), runtimeConfigStr) diff --git a/src/main/core/manager.ts b/src/main/core/manager.ts index 1214d37..0570f82 100644 --- a/src/main/core/manager.ts +++ b/src/main/core/manager.ts @@ -24,7 +24,8 @@ import { stopMihomoConnections, stopMihomoTraffic, stopMihomoLogs, - stopMihomoMemory + stopMihomoMemory, + patchMihomoConfig } from './mihomoApi' import chokidar from 'chokidar' import { readFile, rm, writeFile } from 'fs/promises' @@ -47,6 +48,7 @@ let retry = 10 export async function startCore(detached = false): Promise[]> { const { core = 'mihomo', autoSetDNS = true, encryptedPassword } = await getAppConfig() + const { 'log-level': logLevel } = await getControledMihomoConfig() if (existsSync(path.join(dataDir(), 'core.pid'))) { const pid = parseInt(await readFile(path.join(dataDir(), 'core.pid'), 'utf-8')) try { @@ -136,6 +138,7 @@ export async function startCore(detached = false): Promise[]> { } catch { // ignore } + await patchMihomoConfig({ 'log-level': logLevel }) resolve() } })