mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
feat: support pausing on the connections page
This commit is contained in:
parent
2bf54446df
commit
2eb10df116
@ -540,6 +540,8 @@
|
|||||||
"connections.detail.specialProxy": "Special Proxy",
|
"connections.detail.specialProxy": "Special Proxy",
|
||||||
"connections.detail.specialRules": "Special Rules",
|
"connections.detail.specialRules": "Special Rules",
|
||||||
"connections.detail.close": "Close",
|
"connections.detail.close": "Close",
|
||||||
|
"connections.pause": "Pause",
|
||||||
|
"connections.resume": "Resume",
|
||||||
"resources.geoData.geoip": "GeoIP Database",
|
"resources.geoData.geoip": "GeoIP Database",
|
||||||
"resources.geoData.geosite": "GeoSite Database",
|
"resources.geoData.geosite": "GeoSite Database",
|
||||||
"resources.geoData.mmdb": "MMDB Database",
|
"resources.geoData.mmdb": "MMDB Database",
|
||||||
|
|||||||
@ -515,6 +515,8 @@
|
|||||||
"connections.detail.specialProxy": "پراکسی ویژه",
|
"connections.detail.specialProxy": "پراکسی ویژه",
|
||||||
"connections.detail.specialRules": "قوانین ویژه",
|
"connections.detail.specialRules": "قوانین ویژه",
|
||||||
"connections.detail.close": "بستن",
|
"connections.detail.close": "بستن",
|
||||||
|
"connections.pause": "مکث",
|
||||||
|
"connections.resume": "ادامه",
|
||||||
"resources.geoData.geoip": "پایگاه داده GeoIP",
|
"resources.geoData.geoip": "پایگاه داده GeoIP",
|
||||||
"resources.geoData.geosite": "پایگاه داده GeoSite",
|
"resources.geoData.geosite": "پایگاه داده GeoSite",
|
||||||
"resources.geoData.mmdb": "پایگاه داده MMDB",
|
"resources.geoData.mmdb": "پایگاه داده MMDB",
|
||||||
|
|||||||
@ -515,6 +515,8 @@
|
|||||||
"connections.detail.specialProxy": "Специальный прокси",
|
"connections.detail.specialProxy": "Специальный прокси",
|
||||||
"connections.detail.specialRules": "Специальные правила",
|
"connections.detail.specialRules": "Специальные правила",
|
||||||
"connections.detail.close": "Закрыть",
|
"connections.detail.close": "Закрыть",
|
||||||
|
"connections.pause": "Пауза",
|
||||||
|
"connections.resume": "Продолжить",
|
||||||
"resources.geoData.geoip": "База данных GeoIP",
|
"resources.geoData.geoip": "База данных GeoIP",
|
||||||
"resources.geoData.geosite": "База данных GeoSite",
|
"resources.geoData.geosite": "База данных GeoSite",
|
||||||
"resources.geoData.mmdb": "База данных MMDB",
|
"resources.geoData.mmdb": "База данных MMDB",
|
||||||
|
|||||||
@ -540,6 +540,8 @@
|
|||||||
"connections.detail.specialProxy": "特殊代理",
|
"connections.detail.specialProxy": "特殊代理",
|
||||||
"connections.detail.specialRules": "特殊规则",
|
"connections.detail.specialRules": "特殊规则",
|
||||||
"connections.detail.close": "关闭",
|
"connections.detail.close": "关闭",
|
||||||
|
"connections.pause": "暂停",
|
||||||
|
"connections.resume": "恢复",
|
||||||
"resources.geoData.geoip": "GeoIP 数据库",
|
"resources.geoData.geoip": "GeoIP 数据库",
|
||||||
"resources.geoData.geosite": "GeoSite 数据库",
|
"resources.geoData.geosite": "GeoSite 数据库",
|
||||||
"resources.geoData.mmdb": "MMDB 数据库",
|
"resources.geoData.mmdb": "MMDB 数据库",
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { HiSortAscending, HiSortDescending } from 'react-icons/hi'
|
|||||||
import { includesIgnoreCase } from '@renderer/utils/includes'
|
import { includesIgnoreCase } from '@renderer/utils/includes'
|
||||||
import { differenceWith, unionWith } from 'lodash'
|
import { differenceWith, unionWith } from 'lodash'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { IoMdPause, IoMdPlay } from 'react-icons/io'
|
||||||
|
|
||||||
let cachedConnections: IMihomoConnectionDetail[] = []
|
let cachedConnections: IMihomoConnectionDetail[] = []
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ const Connections: React.FC = () => {
|
|||||||
const [isDetailModalOpen, setIsDetailModalOpen] = useState(false)
|
const [isDetailModalOpen, setIsDetailModalOpen] = useState(false)
|
||||||
const [selected, setSelected] = useState<IMihomoConnectionDetail>()
|
const [selected, setSelected] = useState<IMihomoConnectionDetail>()
|
||||||
const [tab, setTab] = useState('active')
|
const [tab, setTab] = useState('active')
|
||||||
|
const [isPaused, setIsPaused] = useState(false)
|
||||||
|
|
||||||
const filteredConnections = useMemo(() => {
|
const filteredConnections = useMemo(() => {
|
||||||
const connections = tab === 'active' ? activeConnections : closedConnections
|
const connections = tab === 'active' ? activeConnections : closedConnections
|
||||||
@ -93,6 +95,7 @@ const Connections: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (isPaused) return
|
||||||
window.electron.ipcRenderer.on('mihomoConnections', (_e, info: IMihomoConnectionsInfo) => {
|
window.electron.ipcRenderer.on('mihomoConnections', (_e, info: IMihomoConnectionsInfo) => {
|
||||||
setConnectionsInfo(info)
|
setConnectionsInfo(info)
|
||||||
|
|
||||||
@ -131,7 +134,10 @@ const Connections: React.FC = () => {
|
|||||||
return (): void => {
|
return (): void => {
|
||||||
window.electron.ipcRenderer.removeAllListeners('mihomoConnections')
|
window.electron.ipcRenderer.removeAllListeners('mihomoConnections')
|
||||||
}
|
}
|
||||||
}, [allConnections, activeConnections, closedConnections])
|
}, [allConnections, activeConnections, closedConnections, isPaused])
|
||||||
|
const togglePause = () => {
|
||||||
|
setIsPaused(!isPaused)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage
|
<BasePage
|
||||||
@ -153,6 +159,16 @@ const Connections: React.FC = () => {
|
|||||||
showOutline={false}
|
showOutline={false}
|
||||||
content={`${filteredConnections.length}`}
|
content={`${filteredConnections.length}`}
|
||||||
>
|
>
|
||||||
|
<Button
|
||||||
|
className="app-nodrag ml-1"
|
||||||
|
title={isPaused ? t('connections.resume') : t('connections.pause')}
|
||||||
|
isIconOnly
|
||||||
|
size="sm"
|
||||||
|
variant="light"
|
||||||
|
onPress={togglePause}
|
||||||
|
>
|
||||||
|
{isPaused ? <IoMdPlay className="text-lg" /> : <IoMdPause className="text-lg" />}
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
className="app-nodrag ml-1"
|
className="app-nodrag ml-1"
|
||||||
title={t('connections.closeAll')}
|
title={t('connections.closeAll')}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user