fix setPriority

This commit is contained in:
pompurin404 2024-11-14 22:14:25 +08:00
parent 2faa1659dc
commit 13f8705dc6
No known key found for this signature in database
3 changed files with 25 additions and 23 deletions

View File

@ -9,8 +9,7 @@
- 内置 Sub-Store 不使用缓存
- 允许控制是否为 Sub-Store 使用代理
- 允许设置内核进程优先级
- 提高进程优先级
- Windows 允许设置内核进程优先级
### Bug Fixes

View File

@ -100,7 +100,7 @@ export async function startCore(detached = false): Promise<Promise<void>[]> {
stdio: detached ? 'ignore' : undefined
}
)
if (child.pid) {
if (process.platform === 'win32' && child.pid) {
os.setPriority(child.pid, os.constants.priority[mihomoCpuPriority])
}
if (detached) {

View File

@ -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 = () => {
<SelectItem key="4"></SelectItem>
</Select>
</SettingItem>
<SettingItem title="内核进程优先级" divider>
<Select
classNames={{ trigger: 'data-[hover=true]:bg-default-200' }}
className="w-[150px]"
size="sm"
selectedKeys={new Set([mihomoCpuPriority])}
onSelectionChange={async (v) => {
await patchAppConfig({
mihomoCpuPriority: v.currentKey as Priority
})
}}
>
<SelectItem key="PRIORITY_HIGHEST"></SelectItem>
<SelectItem key="PRIORITY_HIGH"></SelectItem>
<SelectItem key="PRIORITY_ABOVE_NORMAL"></SelectItem>
<SelectItem key="PRIORITY_NORMAL"></SelectItem>
<SelectItem key="PRIORITY_BELOW_NORMAL"></SelectItem>
<SelectItem key="PRIORITY_LOW"></SelectItem>
</Select>
</SettingItem>
{platform === 'win32' && (
<SettingItem title="内核进程优先级" divider>
<Select
classNames={{ trigger: 'data-[hover=true]:bg-default-200' }}
className="w-[150px]"
size="sm"
selectedKeys={new Set([mihomoCpuPriority])}
onSelectionChange={async (v) => {
await patchAppConfig({
mihomoCpuPriority: v.currentKey as Priority
})
}}
>
<SelectItem key="PRIORITY_HIGHEST"></SelectItem>
<SelectItem key="PRIORITY_HIGH"></SelectItem>
<SelectItem key="PRIORITY_ABOVE_NORMAL"></SelectItem>
<SelectItem key="PRIORITY_NORMAL"></SelectItem>
<SelectItem key="PRIORITY_BELOW_NORMAL"></SelectItem>
<SelectItem key="PRIORITY_LOW"></SelectItem>
</Select>
</SettingItem>
)}
<SettingItem
title="为不同订阅分别指定工作目录"
actions={