mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 03:13:44 +08:00
feat: add Connections Info to ConnectionsPage
*Add Upload Traffic, Download Traffic and Active Connections to ConnectionsPage. *IConnections uploadTotal and downloadTotal data missing not displayed, add it to ConnectionsPage interface here.
This commit is contained in:
parent
9ef7310fc2
commit
c8cf179ed9
@ -7,6 +7,9 @@
|
|||||||
"Label-Settings": "Settings",
|
"Label-Settings": "Settings",
|
||||||
|
|
||||||
"Connections": "Connections",
|
"Connections": "Connections",
|
||||||
|
"Upload Total": "Upload Total",
|
||||||
|
"Download Total": "Download Total",
|
||||||
|
"Active Connections": "Active Connections",
|
||||||
"Logs": "Logs",
|
"Logs": "Logs",
|
||||||
"Clear": "Clear",
|
"Clear": "Clear",
|
||||||
"Proxies": "Proxies",
|
"Proxies": "Proxies",
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
"Label-Settings": "设 置",
|
"Label-Settings": "设 置",
|
||||||
|
|
||||||
"Connections": "连接",
|
"Connections": "连接",
|
||||||
|
"Upload Total": "上传总量",
|
||||||
|
"Download Total": "下载总量",
|
||||||
|
"Active Connections": "活动连接",
|
||||||
"Logs": "日志",
|
"Logs": "日志",
|
||||||
"Clear": "清除",
|
"Clear": "清除",
|
||||||
"Proxies": "代理",
|
"Proxies": "代理",
|
||||||
|
@ -3,16 +3,24 @@ import { useLockFn } from "ahooks";
|
|||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
|
Grid,
|
||||||
IconButton,
|
IconButton,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
Paper,
|
Paper,
|
||||||
Select,
|
Select,
|
||||||
TextField,
|
TextField,
|
||||||
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { TableChartRounded, TableRowsRounded } from "@mui/icons-material";
|
import {
|
||||||
|
ArrowDownward,
|
||||||
|
ArrowUpward,
|
||||||
|
Link,
|
||||||
|
TableChartRounded,
|
||||||
|
TableRowsRounded,
|
||||||
|
} from "@mui/icons-material";
|
||||||
import { closeAllConnections } from "@/services/api";
|
import { closeAllConnections } from "@/services/api";
|
||||||
import { atomConnectionSetting } from "@/services/states";
|
import { atomConnectionSetting } from "@/services/states";
|
||||||
import { useClashInfo } from "@/hooks/use-clash";
|
import { useClashInfo } from "@/hooks/use-clash";
|
||||||
@ -24,6 +32,7 @@ import {
|
|||||||
ConnectionDetail,
|
ConnectionDetail,
|
||||||
ConnectionDetailRef,
|
ConnectionDetailRef,
|
||||||
} from "@/components/connection/connection-detail";
|
} from "@/components/connection/connection-detail";
|
||||||
|
import parseTraffic from "@/utils/parse-traffic";
|
||||||
|
|
||||||
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
||||||
|
|
||||||
@ -48,6 +57,10 @@ const ConnectionsPage = () => {
|
|||||||
list.sort((a, b) => b.curDownload! - a.curDownload!),
|
list.sort((a, b) => b.curDownload! - a.curDownload!),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const uploadTotal = connData.uploadTotal;
|
||||||
|
|
||||||
|
const downloadTotal = connData.downloadTotal;
|
||||||
|
|
||||||
const filterConn = useMemo(() => {
|
const filterConn = useMemo(() => {
|
||||||
const orderFunc = orderOpts[curOrderOpt];
|
const orderFunc = orderOpts[curOrderOpt];
|
||||||
const connections = connData.connections.filter((conn) =>
|
const connections = connData.connections.filter((conn) =>
|
||||||
@ -112,6 +125,24 @@ const ConnectionsPage = () => {
|
|||||||
|
|
||||||
const detailRef = useRef<ConnectionDetailRef>(null!);
|
const detailRef = useRef<ConnectionDetailRef>(null!);
|
||||||
|
|
||||||
|
const connectionItems = [
|
||||||
|
{
|
||||||
|
icon: <ArrowUpward />,
|
||||||
|
label: t("Upload Total"),
|
||||||
|
value: parseTraffic(uploadTotal).join(" "),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: <ArrowDownward />,
|
||||||
|
label: t("Download Total"),
|
||||||
|
value: parseTraffic(downloadTotal).join(" "),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: <Link />,
|
||||||
|
label: t("Active Connections"),
|
||||||
|
value: filterConn.length,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage
|
<BasePage
|
||||||
title={t("Connections")}
|
title={t("Connections")}
|
||||||
@ -142,7 +173,21 @@ const ConnectionsPage = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Paper sx={{ boxShadow: 2, height: "100%" }}>
|
<Paper sx={{ padding: 2, mb: 2 }}>
|
||||||
|
<Grid container>
|
||||||
|
{connectionItems.map((item, index) => (
|
||||||
|
<Grid item xs={4} key={index}>
|
||||||
|
<Box display="flex" alignItems="center" whiteSpace="nowrap">
|
||||||
|
{item.icon}
|
||||||
|
<Typography sx={{ ml: 1, mr: 1 }}>{item.label}</Typography>
|
||||||
|
<Typography>{item.value}</Typography>
|
||||||
|
</Box>
|
||||||
|
</Grid>
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<Paper sx={{ boxShadow: 2, height: "calc(100% - 56px - 16px)" }}>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
pt: 1,
|
pt: 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user