mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-10 11:40:28 +08:00
feat: add option to hide unavailable proxies in proxy list
This commit is contained in:
parent
e6548a0bc3
commit
52cefa39d3
@ -342,6 +342,8 @@
|
||||
"actions.version.title": "App Version",
|
||||
"theme.editor.title": "Edit Theme",
|
||||
"proxies.title": "Proxy Groups & Nodes",
|
||||
"proxies.hideUnavailable.enabled": "Show Unavailable Proxies",
|
||||
"proxies.hideUnavailable.disabled": "Hide Unavailable Proxies",
|
||||
"proxies.card.title": "ProxyGrp",
|
||||
"proxies.delay.test": "Test",
|
||||
"proxies.delay.timeout": "Timeout",
|
||||
|
||||
@ -318,6 +318,8 @@
|
||||
"actions.version.title": "نسخه برنامه",
|
||||
"theme.editor.title": "ویرایش پوسته",
|
||||
"proxies.title": "گروههای پراکسی و گرهها",
|
||||
"proxies.hideUnavailable.enabled": "نمایش گرههای غیرفعال",
|
||||
"proxies.hideUnavailable.disabled": "پنهان کردن گرههای غیرفعال",
|
||||
"proxies.card.title": "گروهپراکسی",
|
||||
"proxies.delay.test": "تست",
|
||||
"proxies.delay.timeout": "وقفه",
|
||||
|
||||
@ -318,6 +318,8 @@
|
||||
"actions.version.title": "Версия приложения",
|
||||
"theme.editor.title": "Редактор темы",
|
||||
"proxies.title": "Прокси группы и узлы",
|
||||
"proxies.hideUnavailable.enabled": "Показать недоступные узлы",
|
||||
"proxies.hideUnavailable.disabled": "Скрыть недоступные узлы",
|
||||
"proxies.card.title": "Прокси группы",
|
||||
"proxies.delay.test": "Тест",
|
||||
"proxies.delay.timeout": "Таймаут",
|
||||
|
||||
@ -342,6 +342,8 @@
|
||||
"actions.version.title": "应用版本",
|
||||
"theme.editor.title": "编辑主题",
|
||||
"proxies.title": "代理组与节点",
|
||||
"proxies.hideUnavailable.enabled": "显示不可用节点",
|
||||
"proxies.hideUnavailable.disabled": "隐藏不可用节点",
|
||||
"proxies.card.title": "代理组",
|
||||
"proxies.delay.test": "测试",
|
||||
"proxies.delay.timeout": "超时",
|
||||
|
||||
@ -342,6 +342,8 @@
|
||||
"actions.version.title": "應用程式版本",
|
||||
"theme.editor.title": "編輯主題",
|
||||
"proxies.title": "代理組與節點",
|
||||
"proxies.hideUnavailable.enabled": "顯示不可用節點",
|
||||
"proxies.hideUnavailable.disabled": "隱藏不可用節點",
|
||||
"proxies.card.title": "代理組",
|
||||
"proxies.delay.test": "測試",
|
||||
"proxies.delay.timeout": "逾時",
|
||||
|
||||
@ -11,11 +11,11 @@ import { CgDetailsLess, CgDetailsMore } from 'react-icons/cg'
|
||||
import { TbCircleLetterD } from 'react-icons/tb'
|
||||
import { FaLocationCrosshairs } from 'react-icons/fa6'
|
||||
import { RxLetterCaseCapitalize } from 'react-icons/rx'
|
||||
import { MdVisibilityOff, MdDoubleArrow, MdOutlineSpeed } from 'react-icons/md'
|
||||
import { useEffect, useMemo, useRef, useState, useCallback } from 'react'
|
||||
import { GroupedVirtuoso, GroupedVirtuosoHandle } from 'react-virtuoso'
|
||||
import ProxyItem from '@renderer/components/proxies/proxy-item'
|
||||
import { IoIosArrowBack } from 'react-icons/io'
|
||||
import { MdDoubleArrow, MdOutlineSpeed } from 'react-icons/md'
|
||||
import { useGroups } from '@renderer/hooks/use-groups'
|
||||
import CollapseInput from '@renderer/components/base/collapse-input'
|
||||
import { includesIgnoreCase } from '@renderer/utils/includes'
|
||||
@ -160,9 +160,25 @@ const Proxies: React.FC = () => {
|
||||
|
||||
groups.forEach((group, index) => {
|
||||
if (isOpen[index]) {
|
||||
const filtered = group.all.filter(
|
||||
(proxy) => proxy && includesIgnoreCase(proxy.name, searchValue[index])
|
||||
)
|
||||
const filtered = group.all.filter((proxy) => {
|
||||
if (!includesIgnoreCase(proxy.name, searchValue[index])) {
|
||||
return false
|
||||
}
|
||||
if (appConfig?.hideUnavailableProxies) {
|
||||
const isGroup = 'all' in proxy
|
||||
if (isGroup) {
|
||||
return true
|
||||
}
|
||||
if (!proxy.history || proxy.history.length === 0) {
|
||||
return true
|
||||
}
|
||||
const lastDelay = proxy.history[proxy.history.length - 1].delay
|
||||
if (lastDelay === 0) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
const sorted = sortProxies(filtered, proxyDisplayOrder)
|
||||
const count = Math.ceil(sorted.length / cols)
|
||||
groupCounts.push(count)
|
||||
@ -173,7 +189,15 @@ const Proxies: React.FC = () => {
|
||||
}
|
||||
})
|
||||
return { groupCounts, allProxies }
|
||||
}, [groups, isOpen, proxyDisplayOrder, cols, searchValue, sortProxies])
|
||||
}, [
|
||||
groups,
|
||||
isOpen,
|
||||
proxyDisplayOrder,
|
||||
cols,
|
||||
searchValue,
|
||||
sortProxies,
|
||||
appConfig?.hideUnavailableProxies
|
||||
])
|
||||
|
||||
const onChangeProxy = useCallback(
|
||||
async (group: string, proxy: string): Promise<void> => {
|
||||
@ -509,6 +533,26 @@ const Proxies: React.FC = () => {
|
||||
title={t('proxies.title')}
|
||||
header={
|
||||
<>
|
||||
<Button
|
||||
size="sm"
|
||||
isIconOnly
|
||||
variant="light"
|
||||
className="app-nodrag"
|
||||
onPress={() => {
|
||||
patchAppConfig({
|
||||
hideUnavailableProxies: !appConfig?.hideUnavailableProxies
|
||||
})
|
||||
}}
|
||||
>
|
||||
<MdVisibilityOff
|
||||
className={`text-lg ${appConfig?.hideUnavailableProxies ? 'text-warning' : 'text-foreground-500'}`}
|
||||
title={
|
||||
appConfig?.hideUnavailableProxies
|
||||
? t('proxies.hideUnavailable.enabled')
|
||||
: t('proxies.hideUnavailable.disabled')
|
||||
}
|
||||
/>
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
isIconOnly
|
||||
|
||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -229,6 +229,7 @@ interface IAppConfig {
|
||||
profileDisplayDate?: 'expire' | 'update'
|
||||
envType?: ('bash' | 'cmd' | 'powershell')[]
|
||||
proxyCols: 'auto' | '1' | '2' | '3' | '4'
|
||||
hideUnavailableProxies?: boolean
|
||||
connectionDirection: 'asc' | 'desc'
|
||||
connectionOrderBy: 'time' | 'upload' | 'download' | 'uploadSpeed' | 'downloadSpeed'
|
||||
connectionViewMode?: 'list' | 'table'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user