mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 04:33:45 +08:00
refactor: revise data retrieval for homepage traffic stats
This commit is contained in:
parent
fe1227618a
commit
cab8e613a6
@ -182,22 +182,13 @@ export const EnhancedTrafficStats = () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const connections = await getConnections();
|
const connections = await getConnections();
|
||||||
if (connections && connections.connections) {
|
if (connections) {
|
||||||
const uploadTotal = connections.connections.reduce(
|
|
||||||
(sum, conn) => sum + conn.upload,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
const downloadTotal = connections.connections.reduce(
|
|
||||||
(sum, conn) => sum + conn.download,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
|
|
||||||
setStats(prev => ({
|
setStats(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
connections: {
|
connections: {
|
||||||
uploadTotal,
|
uploadTotal: connections.uploadTotal || 0,
|
||||||
downloadTotal,
|
downloadTotal: connections.downloadTotal || 0,
|
||||||
activeConnections: connections.connections.length,
|
activeConnections: connections.connections ? connections.connections.length : 0,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user