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
|
})) 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 => {
|
export const startMihomoTraffic = (): void => {
|
||||||
mihomoTraffic()
|
mihomoTraffic()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import {
|
|||||||
mihomoChangeProxy,
|
mihomoChangeProxy,
|
||||||
mihomoCloseAllConnections,
|
mihomoCloseAllConnections,
|
||||||
mihomoCloseConnection,
|
mihomoCloseConnection,
|
||||||
|
mihomoGroupDelay,
|
||||||
mihomoProxies,
|
mihomoProxies,
|
||||||
mihomoProxyDelay,
|
mihomoProxyDelay,
|
||||||
mihomoProxyProviders,
|
mihomoProxyProviders,
|
||||||
@ -56,6 +57,7 @@ export function registerIpcMainHandlers(): void {
|
|||||||
ipcMain.handle('mihomoChangeProxy', (_e, group, proxy) => mihomoChangeProxy(group, proxy))
|
ipcMain.handle('mihomoChangeProxy', (_e, group, proxy) => mihomoChangeProxy(group, proxy))
|
||||||
ipcMain.handle('mihomoUpgradeGeo', mihomoUpgradeGeo)
|
ipcMain.handle('mihomoUpgradeGeo', mihomoUpgradeGeo)
|
||||||
ipcMain.handle('mihomoProxyDelay', (_e, proxy, url) => mihomoProxyDelay(proxy, url))
|
ipcMain.handle('mihomoProxyDelay', (_e, proxy, url) => mihomoProxyDelay(proxy, url))
|
||||||
|
ipcMain.handle('mihomoGroupDelay', (_e, group, url) => mihomoGroupDelay(group, url))
|
||||||
ipcMain.handle('startMihomoLogs', startMihomoLogs)
|
ipcMain.handle('startMihomoLogs', startMihomoLogs)
|
||||||
ipcMain.handle('stopMihomoLogs', stopMihomoLogs)
|
ipcMain.handle('stopMihomoLogs', stopMihomoLogs)
|
||||||
ipcMain.handle('startMihomoConnections', () => startMihomoConnections())
|
ipcMain.handle('startMihomoConnections', () => startMihomoConnections())
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
import { Avatar, Button, Card, CardBody, Chip } from '@nextui-org/react'
|
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 { mihomoChangeProxy, mihomoProxies, mihomoProxyDelay } from '@renderer/utils/ipc'
|
import {
|
||||||
|
mihomoChangeProxy,
|
||||||
|
mihomoGroupDelay,
|
||||||
|
mihomoProxies,
|
||||||
|
mihomoProxyDelay
|
||||||
|
} from '@renderer/utils/ipc'
|
||||||
import { CgDetailsLess, CgDetailsMore } from 'react-icons/cg'
|
import { CgDetailsLess, CgDetailsMore } from 'react-icons/cg'
|
||||||
import { FaBoltLightning } from 'react-icons/fa6'
|
import { FaBoltLightning } from 'react-icons/fa6'
|
||||||
import { TbCircleLetterD } from 'react-icons/tb'
|
import { TbCircleLetterD } from 'react-icons/tb'
|
||||||
@ -79,8 +84,9 @@ const Proxies: React.FC = () => {
|
|||||||
return await mihomoProxyDelay(proxy, url)
|
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`)
|
PubSub.publish(`${group}-delay`)
|
||||||
|
await mihomoGroupDelay(group, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -211,7 +217,7 @@ const Proxies: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
isIconOnly
|
isIconOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
onGroupDelay(groups[index].name)
|
onGroupDelay(groups[index].name, groups[index].testUrl)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MdOutlineSpeed className="text-lg text-default-500" />
|
<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> {
|
export async function mihomoProxyDelay(proxy: string, url?: string): Promise<IMihomoDelay> {
|
||||||
const res = await window.electron.ipcRenderer.invoke('mihomoProxyDelay', proxy, url)
|
return await window.electron.ipcRenderer.invoke('mihomoProxyDelay', proxy, url)
|
||||||
return res
|
}
|
||||||
|
|
||||||
|
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> {
|
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
|
delay: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IMihomoGroupDelay = Record<string, number>
|
||||||
|
|
||||||
interface IMihomoDelay {
|
interface IMihomoDelay {
|
||||||
delay?: number
|
delay?: number
|
||||||
message?: string
|
message?: string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user