From 74c006522e23aa52cf8979a8fb47d2b1ae0bb043 Mon Sep 17 00:00:00 2001 From: oomeow Date: Sat, 4 Oct 2025 12:15:33 +0800 Subject: [PATCH] fix: parse bigint to number --- src/components/proxy/provider-button.tsx | 26 ++++++------------------ src/components/rule/provider-button.tsx | 14 +++---------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/components/proxy/provider-button.tsx b/src/components/proxy/provider-button.tsx index 89c7c500..d444ea8e 100644 --- a/src/components/proxy/provider-button.tsx +++ b/src/components/proxy/provider-button.tsx @@ -20,25 +20,11 @@ import { useLockFn } from "ahooks"; import dayjs from "dayjs"; import { useState } from "react"; import { useTranslation } from "react-i18next"; +import { updateProxyProvider } from "tauri-plugin-mihomo-api"; import { useAppData } from "@/providers/app-data-provider"; import { showNotice } from "@/services/noticeService"; import parseTraffic from "@/utils/parse-traffic"; -import { updateProxyProvider } from "tauri-plugin-mihomo-api"; - -// 定义代理提供者类型 -interface ProxyProviderItem { - name?: string; - proxies: any[]; - updatedAt: number; - vehicleType: string; - subscriptionInfo?: { - Upload: number; - Download: number; - Total: number; - Expire: number; - }; -} // 样式化组件 - 类型框 const TypeBox = styled(Box)<{ component?: React.ElementType }>(({ theme }) => ({ @@ -180,17 +166,17 @@ export const ProviderButton = () => { {Object.entries(proxyProviders || {}) .sort() .map(([key, item]) => { - const provider = item as ProxyProviderItem; + const provider = item; const time = dayjs(provider.updatedAt); const isUpdating = updating[key]; // 订阅信息 const sub = provider.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 upload = parseInt(sub?.Upload.toString() || "0"); + const download = parseInt(sub?.Download.toString() || "0"); + const total = parseInt(sub?.Total.toString() || "0"); + const expire = parseInt(sub?.Expire.toString() || "0"); // 流量使用进度 const progress = diff --git a/src/components/rule/provider-button.tsx b/src/components/rule/provider-button.tsx index 7cce5939..e485b817 100644 --- a/src/components/rule/provider-button.tsx +++ b/src/components/rule/provider-button.tsx @@ -19,18 +19,10 @@ import { useLockFn } from "ahooks"; import dayjs from "dayjs"; import { useState } from "react"; import { useTranslation } from "react-i18next"; - -import { showNotice } from "@/services/noticeService"; import { updateRuleProvider } from "tauri-plugin-mihomo-api"; -import { useAppData } from "@/providers/app-data-provider"; -// 定义规则提供者类型 -interface RuleProviderItem { - behavior: string; - ruleCount: number; - updatedAt: number; - vehicleType: string; -} +import { useAppData } from "@/providers/app-data-provider"; +import { showNotice } from "@/services/noticeService"; // 辅助组件 - 类型框 const TypeBox = styled(Box)<{ component?: React.ElementType }>(({ theme }) => ({ @@ -163,7 +155,7 @@ export const ProviderButton = () => { {Object.entries(ruleProviders || {}) .sort() .map(([key, item]) => { - const provider = item as RuleProviderItem; + const provider = item; const time = dayjs(provider.updatedAt); const isUpdating = updating[key];