diff --git a/frontend/interface/service/types.ts b/frontend/interface/service/types.ts index 45db58cf58..4c28781586 100644 --- a/frontend/interface/service/types.ts +++ b/frontend/interface/service/types.ts @@ -188,6 +188,12 @@ export interface ProviderItem { proxies: Clash.Proxy[]; updatedAt: string; vehicleType: string; + subscriptionInfo?: { + Upload?: number; + Download?: number; + Total?: number; + Expire?: number; + }; } export interface Traffic { diff --git a/frontend/nyanpasu/src/components/providers/proxies-provider-traffic.tsx b/frontend/nyanpasu/src/components/providers/proxies-provider-traffic.tsx new file mode 100644 index 0000000000..835e00516b --- /dev/null +++ b/frontend/nyanpasu/src/components/providers/proxies-provider-traffic.tsx @@ -0,0 +1,45 @@ +import parseTraffic from "@/utils/parse-traffic"; +import { LinearProgress, Tooltip } from "@mui/material"; +import { ProxiesProviderProps } from "./proxies-provider"; + +export const ProxiesProviderTraffic = ({ provider }: ProxiesProviderProps) => { + const calc = () => { + let progress = 0; + let total = 0; + let used = 0; + + if (provider.subscriptionInfo) { + const { + Download: download, + Upload: upload, + Total: t, + } = provider.subscriptionInfo; + + total = t ?? 0; + + used = (download ?? 0) + (upload ?? 0); + + progress = (used / (total ?? 0)) * 100; + } + + return { progress, total, used }; + }; + + const { progress, total, used } = calc(); + + return ( +