diff --git a/src/components/proxy/provider-button.tsx b/src/components/proxy/provider-button.tsx index d5c93781..ce1a1d8b 100644 --- a/src/components/proxy/provider-button.tsx +++ b/src/components/proxy/provider-button.tsx @@ -12,12 +12,14 @@ import { alpha, Typography, Divider, + LinearProgress, } from "@mui/material"; import { RefreshRounded } from "@mui/icons-material"; import { useTranslation } from "react-i18next"; import { useLockFn } from "ahooks"; import { getProxyProviders, proxyProviderUpdate } from "@/services/api"; import { BaseDialog } from "../base"; +import parseTraffic from "@/utils/parse-traffic"; export const ProviderButton = () => { const { t } = useTranslation(); @@ -74,10 +76,28 @@ export const ProviderButton = () => { {Object.entries(data || {}).map(([key, item]) => { const time = dayjs(item.updatedAt); + const sub = item.subscriptionInfo; + const hasSubInfo = !!sub; + const upload = sub?.Upload || 0; + const download = sub?.Download || 0; + const total = sub?.Total || 0; + const expire = sub?.Expire || 0; + const progress = Math.round( + ((download + upload) * 100) / (total + 0.1) + ); return ( <> - + ({ + p: 0, + borderRadius: "10px", + boxShadow: theme.shadows[2], + mb: 1, + })} + key={key} + > { {t("Update At")} {time.fromNow()} + {hasSubInfo && ( + <> + + + {parseTraffic(upload + download)} /{" "} + {parseTraffic(total)} + + + {parseExpire(expire)} + + + + + + )} } /> + { - ); })} @@ -131,3 +170,15 @@ const StyledTypeBox = styled(Box)(({ theme }) => ({ padding: "0 2px", lineHeight: 1.25, })); + +const boxStyle = { + height: 26, + display: "flex", + alignItems: "center", + justifyContent: "space-between", +}; + +function parseExpire(expire?: number) { + if (!expire) return "-"; + return dayjs(expire * 1000).format("YYYY-MM-DD"); +} diff --git a/src/components/rule/provider-button.tsx b/src/components/rule/provider-button.tsx index 0379f8cf..3ab0b48e 100644 --- a/src/components/rule/provider-button.tsx +++ b/src/components/rule/provider-button.tsx @@ -76,8 +76,17 @@ export const ProviderButton = () => { const time = dayjs(item.updatedAt); return ( <> - + ({ + p: 0, + borderRadius: "10px", + boxShadow: theme.shadows[2], + mb: 1, + })} + key={key} + > { } /> + { - ); })} diff --git a/src/services/types.d.ts b/src/services/types.d.ts index c080965d..70a57fa6 100644 --- a/src/services/types.d.ts +++ b/src/services/types.d.ts @@ -67,6 +67,12 @@ interface IProxyProviderItem { proxies: IProxyItem[]; updatedAt: string; vehicleType: string; + subscriptionInfo?: { + Upload: number; + Download: number; + Total: number; + Expire: number; + }; } interface IRuleProviderItem {