mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 11:42:19 +08:00
use delete to unfixed proxy
This commit is contained in:
parent
91395d4b31
commit
09815f9614
|
@ -149,6 +149,10 @@ export const mihomoChangeProxy = async (group: string, proxy: string): Promise<I
|
||||||
return await mihomoHttp('PUT', `/proxies/${encodeURIComponent(group)}`, { name: proxy })
|
return await mihomoHttp('PUT', `/proxies/${encodeURIComponent(group)}`, { name: proxy })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const mihomoUnfixedProxy = async (group: string): Promise<void> => {
|
||||||
|
return await mihomoHttp('DELETE', `/proxies/${encodeURIComponent(group)}`)
|
||||||
|
}
|
||||||
|
|
||||||
export const mihomoUpgradeGeo = async (): Promise<void> => {
|
export const mihomoUpgradeGeo = async (): Promise<void> => {
|
||||||
return await mihomoHttp('POST', '/configs/geo')
|
return await mihomoHttp('POST', '/configs/geo')
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
mihomoProxyProviders,
|
mihomoProxyProviders,
|
||||||
mihomoRuleProviders,
|
mihomoRuleProviders,
|
||||||
mihomoRules,
|
mihomoRules,
|
||||||
|
mihomoUnfixedProxy,
|
||||||
mihomoUpdateProxyProviders,
|
mihomoUpdateProxyProviders,
|
||||||
mihomoUpdateRuleProviders,
|
mihomoUpdateRuleProviders,
|
||||||
mihomoUpgrade,
|
mihomoUpgrade,
|
||||||
|
@ -120,6 +121,7 @@ export function registerIpcMainHandlers(): void {
|
||||||
ipcMain.handle('mihomoChangeProxy', (_e, group, proxy) =>
|
ipcMain.handle('mihomoChangeProxy', (_e, group, proxy) =>
|
||||||
ipcErrorWrapper(mihomoChangeProxy)(group, proxy)
|
ipcErrorWrapper(mihomoChangeProxy)(group, proxy)
|
||||||
)
|
)
|
||||||
|
ipcMain.handle('mihomoUnfixedProxy', (_e, group) => ipcErrorWrapper(mihomoUnfixedProxy)(group))
|
||||||
ipcMain.handle('mihomoUpgradeGeo', ipcErrorWrapper(mihomoUpgradeGeo))
|
ipcMain.handle('mihomoUpgradeGeo', ipcErrorWrapper(mihomoUpgradeGeo))
|
||||||
ipcMain.handle('mihomoUpgrade', ipcErrorWrapper(mihomoUpgrade))
|
ipcMain.handle('mihomoUpgrade', ipcErrorWrapper(mihomoUpgrade))
|
||||||
ipcMain.handle('mihomoProxyDelay', (_e, proxy, url) =>
|
ipcMain.handle('mihomoProxyDelay', (_e, proxy, url) =>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Button, Card, CardBody } from '@nextui-org/react'
|
import { Button, Card, CardBody } from '@nextui-org/react'
|
||||||
import { mihomoGroupDelay } from '@renderer/utils/ipc'
|
import { mihomoUnfixedProxy } from '@renderer/utils/ipc'
|
||||||
import React, { useMemo, useState } from 'react'
|
import React, { useMemo, useState } from 'react'
|
||||||
import { FaMapPin } from 'react-icons/fa6'
|
import { FaMapPin } from 'react-icons/fa6'
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ const ProxyItem: React.FC<Props> = (props) => {
|
||||||
}, [proxy])
|
}, [proxy])
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [unfixing, setUnfixing] = useState(false)
|
|
||||||
function delayColor(delay: number): 'primary' | 'success' | 'warning' | 'danger' {
|
function delayColor(delay: number): 'primary' | 'success' | 'warning' | 'danger' {
|
||||||
if (delay === -1) return 'primary'
|
if (delay === -1) return 'primary'
|
||||||
if (delay === 0) return 'danger'
|
if (delay === 0) return 'danger'
|
||||||
|
@ -74,13 +73,10 @@ const ProxyItem: React.FC<Props> = (props) => {
|
||||||
<Button
|
<Button
|
||||||
isIconOnly
|
isIconOnly
|
||||||
title="取消固定"
|
title="取消固定"
|
||||||
isLoading={unfixing}
|
|
||||||
color="danger"
|
color="danger"
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
setUnfixing(true)
|
await mihomoUnfixedProxy(group.name)
|
||||||
await mihomoGroupDelay(group.name)
|
|
||||||
mutateProxies()
|
mutateProxies()
|
||||||
setUnfixing(false)
|
|
||||||
}}
|
}}
|
||||||
variant="light"
|
variant="light"
|
||||||
className="h-[20px] p-0 text-sm"
|
className="h-[20px] p-0 text-sm"
|
||||||
|
|
|
@ -59,6 +59,10 @@ export async function mihomoChangeProxy(group: string, proxy: string): Promise<I
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function mihomoUnfixedProxy(group: string): Promise<IMihomoProxy> {
|
||||||
|
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoUnfixedProxy', group))
|
||||||
|
}
|
||||||
|
|
||||||
export async function mihomoUpgradeGeo(): Promise<void> {
|
export async function mihomoUpgradeGeo(): Promise<void> {
|
||||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoUpgradeGeo'))
|
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoUpgradeGeo'))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user