From 13f8705dc6a9552fa671154b797276dc5da0c206 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Thu, 14 Nov 2024 22:14:25 +0800 Subject: [PATCH] fix setPriority --- changelog.md | 3 +- src/main/core/manager.ts | 2 +- .../src/components/settings/mihomo-config.tsx | 43 ++++++++++--------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/changelog.md b/changelog.md index d315a7f..6af979b 100644 --- a/changelog.md +++ b/changelog.md @@ -9,8 +9,7 @@ - 内置 Sub-Store 不使用缓存 - 允许控制是否为 Sub-Store 使用代理 -- 允许设置内核进程优先级 -- 提高进程优先级 +- Windows 允许设置内核进程优先级 ### Bug Fixes diff --git a/src/main/core/manager.ts b/src/main/core/manager.ts index f161818..103862f 100644 --- a/src/main/core/manager.ts +++ b/src/main/core/manager.ts @@ -100,7 +100,7 @@ export async function startCore(detached = false): Promise[]> { stdio: detached ? 'ignore' : undefined } ) - if (child.pid) { + if (process.platform === 'win32' && child.pid) { os.setPriority(child.pid, os.constants.priority[mihomoCpuPriority]) } if (detached) { diff --git a/src/renderer/src/components/settings/mihomo-config.tsx b/src/renderer/src/components/settings/mihomo-config.tsx index 12bca14..7cfda65 100644 --- a/src/renderer/src/components/settings/mihomo-config.tsx +++ b/src/renderer/src/components/settings/mihomo-config.tsx @@ -8,6 +8,7 @@ import { getGistUrl, patchControledMihomoConfig, restartCore } from '@renderer/u import { MdDeleteForever } from 'react-icons/md' import { BiCopy } from 'react-icons/bi' import { IoIosHelpCircle } from 'react-icons/io' +import { platform } from '@renderer/utils/init' const MihomoConfig: React.FC = () => { const { appConfig, patchAppConfig } = useAppConfig() @@ -136,26 +137,28 @@ const MihomoConfig: React.FC = () => { 四列 - - - + {platform === 'win32' && ( + + + + )}