mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-10 19:50:28 +08:00
change mihomo core
This commit is contained in:
parent
f583bef224
commit
12504704a3
@ -7,7 +7,7 @@ import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import useSWR from 'swr'
|
||||
|
||||
const MihomoCoreCard: React.FC = () => {
|
||||
const { data: version } = useSWR('mihomoVersion', mihomoVersion)
|
||||
const { data: version, mutate } = useSWR('mihomoVersion', mihomoVersion)
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const match = location.pathname.includes('/mihomo')
|
||||
@ -15,10 +15,17 @@ const MihomoCoreCard: React.FC = () => {
|
||||
const [mem, setMem] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
const token = PubSub.subscribe('mihomo-core-changed', () => {
|
||||
mutate()
|
||||
setTimeout(() => {
|
||||
mutate()
|
||||
}, 1000)
|
||||
})
|
||||
window.electron.ipcRenderer.on('mihomoMemory', (_e, info: IMihomoMemoryInfo) => {
|
||||
setMem(info.inuse)
|
||||
})
|
||||
return (): void => {
|
||||
PubSub.unsubscribe(token)
|
||||
window.electron.ipcRenderer.removeAllListeners('mihomoMemory')
|
||||
}
|
||||
}, [])
|
||||
|
||||
@ -8,7 +8,7 @@ const RuleCard: React.FC = () => {
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const match = location.pathname.includes('/rules')
|
||||
const { data: rules } = useSWR<IMihomoRulesInfo>('/rules', mihomoRules, {
|
||||
const { data: rules } = useSWR<IMihomoRulesInfo>('mihomoRules', mihomoRules, {
|
||||
refreshInterval: 5000
|
||||
})
|
||||
|
||||
|
||||
@ -2,11 +2,19 @@ import { Button, Input, Select, SelectItem, Switch } from '@nextui-org/react'
|
||||
import BasePage from '@renderer/components/base/base-page'
|
||||
import SettingCard from '@renderer/components/base/base-setting-card'
|
||||
import SettingItem from '@renderer/components/base/base-setting-item'
|
||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||
import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config'
|
||||
import { patchMihomoConfig, restartCore } from '@renderer/utils/ipc'
|
||||
import React, { useState } from 'react'
|
||||
|
||||
const CoreMap = {
|
||||
mihomo: '稳定版',
|
||||
'mihomo-alpha': '预览版'
|
||||
}
|
||||
|
||||
const Mihomo: React.FC = () => {
|
||||
const { appConfig, patchAppConfig } = useAppConfig()
|
||||
const { core = 'mihomo' } = appConfig || {}
|
||||
const { controledMihomoConfig, patchControledMihomoConfig } = useControledMihomoConfig()
|
||||
const {
|
||||
ipv6,
|
||||
@ -34,6 +42,20 @@ const Mihomo: React.FC = () => {
|
||||
return (
|
||||
<BasePage title="内核设置">
|
||||
<SettingCard>
|
||||
<SettingItem title="内核版本" divider>
|
||||
<Select
|
||||
className="w-[100px]"
|
||||
size="sm"
|
||||
selectedKeys={new Set([core])}
|
||||
onSelectionChange={async (v) => {
|
||||
await patchAppConfig({ core: v.currentKey as 'mihomo' | 'mihomo-alpha' })
|
||||
restartCore().then(() => PubSub.publish('mihomo-core-changed'))
|
||||
}}
|
||||
>
|
||||
<SelectItem key="mihomo">{CoreMap['mihomo']}</SelectItem>
|
||||
<SelectItem key="mihomo-alpha">{CoreMap['mihomo-alpha']}</SelectItem>
|
||||
</Select>
|
||||
</SettingItem>
|
||||
<SettingItem title="混合端口" divider>
|
||||
<div className="flex">
|
||||
{mixedPortInput !== mixedPort && (
|
||||
|
||||
@ -6,7 +6,7 @@ import useSWR from 'swr'
|
||||
import { mihomoRules } from '@renderer/utils/ipc'
|
||||
|
||||
const Rules: React.FC = () => {
|
||||
const { data: rules = { rules: [] } } = useSWR<IMihomoRulesInfo>('/rules', mihomoRules, {
|
||||
const { data: rules = { rules: [] } } = useSWR<IMihomoRulesInfo>('mihomoRules', mihomoRules, {
|
||||
refreshInterval: 5000
|
||||
})
|
||||
const [filter, setFilter] = useState('')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user