mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-28 05:30:29 +08:00
use proxy-group url
This commit is contained in:
parent
08c00ae77f
commit
3d0f75242e
@ -2,6 +2,7 @@ import { Avatar, Button, Card, CardBody, Chip } from '@nextui-org/react'
|
|||||||
import BasePage from '@renderer/components/base/base-page'
|
import BasePage from '@renderer/components/base/base-page'
|
||||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||||
import {
|
import {
|
||||||
|
getRuntimeConfig,
|
||||||
mihomoChangeProxy,
|
mihomoChangeProxy,
|
||||||
mihomoGroupDelay,
|
mihomoGroupDelay,
|
||||||
mihomoProxies,
|
mihomoProxies,
|
||||||
@ -21,29 +22,31 @@ import { MdOutlineSpeed } from 'react-icons/md'
|
|||||||
|
|
||||||
const Proxies: React.FC = () => {
|
const Proxies: React.FC = () => {
|
||||||
const { data: proxies, mutate } = useSWR('mihomoProxies', mihomoProxies)
|
const { data: proxies, mutate } = useSWR('mihomoProxies', mihomoProxies)
|
||||||
|
const { data: runtime } = useSWR('getRuntimeConfig', getRuntimeConfig)
|
||||||
const { appConfig, patchAppConfig } = useAppConfig()
|
const { appConfig, patchAppConfig } = useAppConfig()
|
||||||
const { proxyDisplayMode = 'simple', proxyDisplayOrder = 'default' } = appConfig || {}
|
const { proxyDisplayMode = 'simple', proxyDisplayOrder = 'default' } = appConfig || {}
|
||||||
|
|
||||||
const groups = useMemo(() => {
|
const groups = useMemo(() => {
|
||||||
const groups: IMihomoGroup[] = []
|
const groups: IMihomoGroup[] = []
|
||||||
if (proxies && proxies.proxies && proxies.proxies['GLOBAL']) {
|
if (proxies && proxies.proxies) {
|
||||||
const globalGroup = proxies.proxies['GLOBAL'] as IMihomoGroup
|
runtime?.['proxy-groups']?.forEach((group: { name: string; url?: string }) => {
|
||||||
for (const global of globalGroup.all) {
|
const { name, url } = group
|
||||||
if (isGroup(proxies.proxies[global])) {
|
if (
|
||||||
if (proxies.proxies[global].hidden) continue
|
proxies.proxies[name] &&
|
||||||
groups.push(proxies.proxies[global] as IMihomoGroup)
|
isGroup(proxies.proxies[name]) &&
|
||||||
}
|
!proxies.proxies[name].hidden
|
||||||
}
|
) {
|
||||||
Object.keys(proxies.proxies).forEach((key) => {
|
const newGroup = proxies.proxies[name]
|
||||||
if (isGroup(proxies.proxies[key])) {
|
newGroup.testUrl = url
|
||||||
if (!groups.find((group) => group.name === key)) {
|
groups.push(newGroup as IMihomoGroup)
|
||||||
if (proxies.proxies[key].hidden) return
|
|
||||||
groups.push(proxies.proxies[key] as IMihomoGroup)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (!groups.find((group) => group.name === 'GLOBAL')) {
|
||||||
|
groups.push(proxies.proxies['GLOBAL'] as IMihomoGroup)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return groups
|
return groups
|
||||||
}, [proxies])
|
}, [proxies, runtime])
|
||||||
|
|
||||||
const [isOpen, setIsOpen] = useState(Array(groups.length).fill(false))
|
const [isOpen, setIsOpen] = useState(Array(groups.length).fill(false))
|
||||||
const virtuosoRef = useRef<GroupedVirtuosoHandle>(null)
|
const virtuosoRef = useRef<GroupedVirtuosoHandle>(null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user