mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-12 21:52:13 +08:00
fix: use mihomo traffic totals
This commit is contained in:
@@ -167,11 +167,9 @@ export const EnhancedTrafficStats = () => {
|
||||
const [up, upUnit] = parseTraffic(traffic?.up || 0)
|
||||
const [down, downUnit] = parseTraffic(traffic?.down || 0)
|
||||
const [inuse, inuseUnit] = parseTraffic(memory?.inuse || 0)
|
||||
const [uploadTotal, uploadTotalUnit] = parseTraffic(
|
||||
connectionSummary?.uploadTotal,
|
||||
)
|
||||
const [uploadTotal, uploadTotalUnit] = parseTraffic(traffic?.upTotal || 0)
|
||||
const [downloadTotal, downloadTotalUnit] = parseTraffic(
|
||||
connectionSummary?.downloadTotal,
|
||||
traffic?.downTotal || 0,
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
@@ -25,14 +25,10 @@ export interface ConnectionMonitorData {
|
||||
}
|
||||
|
||||
export interface ConnectionSummaryData {
|
||||
uploadTotal: number
|
||||
downloadTotal: number
|
||||
activeConnectionCount: number
|
||||
}
|
||||
|
||||
export const initConnSummaryData: ConnectionSummaryData = {
|
||||
uploadTotal: 0,
|
||||
downloadTotal: 0,
|
||||
activeConnectionCount: 0,
|
||||
}
|
||||
|
||||
@@ -212,8 +208,6 @@ const mergeConnectionSnapshot = (
|
||||
const mergeConnectionSummary = (
|
||||
payload: IConnections,
|
||||
): ConnectionSummaryData => ({
|
||||
uploadTotal: payload.uploadTotal ?? 0,
|
||||
downloadTotal: payload.downloadTotal ?? 0,
|
||||
activeConnectionCount: payload.connections?.length ?? 0,
|
||||
})
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ let lastTrafficTimestamp = 0
|
||||
|
||||
const shouldSkipDuplicateTraffic = (traffic: Traffic) => {
|
||||
const now = Date.now()
|
||||
const signature = `${traffic.up}:${traffic.down}`
|
||||
const signature = `${traffic.up}:${traffic.down}:${traffic.upTotal}:${traffic.downTotal}`
|
||||
|
||||
if (
|
||||
signature === lastTrafficSignature &&
|
||||
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
import { ConnectionTable } from '@/components/connection/connection-table'
|
||||
import { useConnectionData } from '@/hooks/use-connection-data'
|
||||
import { useConnectionSetting } from '@/hooks/use-connection-setting'
|
||||
import { useTrafficData } from '@/hooks/use-traffic-data'
|
||||
import parseTraffic from '@/utils/parse-traffic'
|
||||
|
||||
type OrderFunc = (list: IConnectionsItem[]) => IConnectionsItem[]
|
||||
@@ -92,6 +93,9 @@ const ConnectionsPage = () => {
|
||||
response: { data: connections },
|
||||
clearClosedConnections,
|
||||
} = useConnectionData()
|
||||
const {
|
||||
response: { data: traffic },
|
||||
} = useTrafficData()
|
||||
|
||||
const [setting, setSetting] = useConnectionSetting()
|
||||
|
||||
@@ -177,11 +181,10 @@ const ConnectionsPage = () => {
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
||||
<Box sx={{ mx: 1 }}>
|
||||
{t('shared.labels.downloaded')}:{' '}
|
||||
{parseTraffic(connections?.downloadTotal)}
|
||||
{parseTraffic(traffic?.downTotal || 0)}
|
||||
</Box>
|
||||
<Box sx={{ mx: 1 }}>
|
||||
{t('shared.labels.uploaded')}:{' '}
|
||||
{parseTraffic(connections?.uploadTotal)}
|
||||
{t('shared.labels.uploaded')}: {parseTraffic(traffic?.upTotal || 0)}
|
||||
</Box>
|
||||
<IconButton
|
||||
color="inherit"
|
||||
|
||||
Reference in New Issue
Block a user