mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
fix group delay
This commit is contained in:
parent
52b058e0c7
commit
90606b1283
@ -136,6 +136,22 @@ export const mihomoProxyDelay = async (proxy: string, url?: string): Promise<IMi
|
||||
})) as IMihomoDelay
|
||||
}
|
||||
|
||||
export const mihomoGroupDelay = async (group: string, url?: string): Promise<IMihomoGroupDelay> => {
|
||||
const appConfig = getAppConfig()
|
||||
const { delayTestUrl, delayTestTimeout } = appConfig
|
||||
const instance = await getAxios()
|
||||
return (await instance
|
||||
.get(`/group/${encodeURIComponent(group)}/delay`, {
|
||||
params: {
|
||||
url: url || delayTestUrl || 'https://www.gstatic.com/generate_204',
|
||||
timeout: delayTestTimeout || 5000
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
return e.response.data
|
||||
})) as IMihomoGroupDelay
|
||||
}
|
||||
|
||||
export const startMihomoTraffic = (): void => {
|
||||
mihomoTraffic()
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import {
|
||||
mihomoChangeProxy,
|
||||
mihomoCloseAllConnections,
|
||||
mihomoCloseConnection,
|
||||
mihomoGroupDelay,
|
||||
mihomoProxies,
|
||||
mihomoProxyDelay,
|
||||
mihomoProxyProviders,
|
||||
@ -56,6 +57,7 @@ export function registerIpcMainHandlers(): void {
|
||||
ipcMain.handle('mihomoChangeProxy', (_e, group, proxy) => mihomoChangeProxy(group, proxy))
|
||||
ipcMain.handle('mihomoUpgradeGeo', mihomoUpgradeGeo)
|
||||
ipcMain.handle('mihomoProxyDelay', (_e, proxy, url) => mihomoProxyDelay(proxy, url))
|
||||
ipcMain.handle('mihomoGroupDelay', (_e, group, url) => mihomoGroupDelay(group, url))
|
||||
ipcMain.handle('startMihomoLogs', startMihomoLogs)
|
||||
ipcMain.handle('stopMihomoLogs', stopMihomoLogs)
|
||||
ipcMain.handle('startMihomoConnections', () => startMihomoConnections())
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
import { Avatar, Button, Card, CardBody, Chip } from '@nextui-org/react'
|
||||
import BasePage from '@renderer/components/base/base-page'
|
||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||
import { mihomoChangeProxy, mihomoProxies, mihomoProxyDelay } from '@renderer/utils/ipc'
|
||||
import {
|
||||
mihomoChangeProxy,
|
||||
mihomoGroupDelay,
|
||||
mihomoProxies,
|
||||
mihomoProxyDelay
|
||||
} from '@renderer/utils/ipc'
|
||||
import { CgDetailsLess, CgDetailsMore } from 'react-icons/cg'
|
||||
import { FaBoltLightning } from 'react-icons/fa6'
|
||||
import { TbCircleLetterD } from 'react-icons/tb'
|
||||
@ -79,8 +84,9 @@ const Proxies: React.FC = () => {
|
||||
return await mihomoProxyDelay(proxy, url)
|
||||
}
|
||||
|
||||
const onGroupDelay = async (group: string): Promise<void> => {
|
||||
const onGroupDelay = async (group: string, url?: string): Promise<void> => {
|
||||
PubSub.publish(`${group}-delay`)
|
||||
await mihomoGroupDelay(group, url)
|
||||
}
|
||||
|
||||
return (
|
||||
@ -211,7 +217,7 @@ const Proxies: React.FC = () => {
|
||||
size="sm"
|
||||
isIconOnly
|
||||
onPress={() => {
|
||||
onGroupDelay(groups[index].name)
|
||||
onGroupDelay(groups[index].name, groups[index].testUrl)
|
||||
}}
|
||||
>
|
||||
<MdOutlineSpeed className="text-lg text-default-500" />
|
||||
|
||||
@ -43,8 +43,11 @@ export async function mihomoUpgradeGeo(): Promise<void> {
|
||||
}
|
||||
|
||||
export async function mihomoProxyDelay(proxy: string, url?: string): Promise<IMihomoDelay> {
|
||||
const res = await window.electron.ipcRenderer.invoke('mihomoProxyDelay', proxy, url)
|
||||
return res
|
||||
return await window.electron.ipcRenderer.invoke('mihomoProxyDelay', proxy, url)
|
||||
}
|
||||
|
||||
export async function mihomoGroupDelay(group: string, url?: string): Promise<IMihomoGroupDelay> {
|
||||
return await window.electron.ipcRenderer.invoke('mihomoGroupDelay', group, url)
|
||||
}
|
||||
|
||||
export async function startMihomoLogs(): Promise<void> {
|
||||
|
||||
2
src/shared/types.d.ts
vendored
2
src/shared/types.d.ts
vendored
@ -107,6 +107,8 @@ interface IMihomoHistory {
|
||||
delay: number
|
||||
}
|
||||
|
||||
type IMihomoGroupDelay = Record<string, number>
|
||||
|
||||
interface IMihomoDelay {
|
||||
delay?: number
|
||||
message?: string
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user