变更流量计费方法

This commit is contained in:
qaq
2025-08-01 16:25:16 +08:00
parent c56e647358
commit f35e6e95f5
11 changed files with 70 additions and 119 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ export type SiteConfig = typeof siteConfig;
// 缓存相关常量
const CACHE_PREFIX = 'vite_config_';
const VERSION = "1.1.1";
const VERSION = "1.2.0";
// 缓存策略:
// - 长期有效,不设置过期时间
+5 -15
View File
@@ -258,6 +258,7 @@ export default function DashboardPage() {
};
const calculateUserTotalUsedFlow = (): number => {
// 后端已按计费类型处理流量,前端直接使用入站+出站总和
return (userInfo.inFlow || 0) + (userInfo.outFlow || 0);
};
@@ -313,11 +314,8 @@ export default function DashboardPage() {
if (!tunnel) return 0;
const inFlow = tunnel.inFlow || 0;
const outFlow = tunnel.outFlow || 0;
if (tunnel.tunnelFlow === 1) {
return outFlow;
} else {
return inFlow + outFlow;
}
// 后端已按计费类型处理流量,前端直接使用入站+出站总和
return inFlow + outFlow;
};
const calculateTunnelFlowPercentage = (tunnel: UserTunnel): number => {
@@ -523,19 +521,11 @@ export default function DashboardPage() {
const calculateForwardBillingFlow = (forward: Forward): number => {
if (!forward) return 0;
const tunnel = userTunnels.find(t => t.tunnelId === forward.tunnelId);
if (!tunnel) {
return (forward.inFlow || 0) + (forward.outFlow || 0);
}
const inFlow = forward.inFlow || 0;
const outFlow = forward.outFlow || 0;
if (tunnel.tunnelFlow === 1) {
return outFlow;
} else {
return inFlow + outFlow;
}
// 后端已按计费类型处理流量,前端直接使用入站+出站总和
return inFlow + outFlow;
};
if (loading) {
+2 -5
View File
@@ -98,11 +98,8 @@ const calculateTunnelUsedFlow = (tunnel: UserTunnel): number => {
const inFlow = tunnel.inFlow || 0;
const outFlow = tunnel.outFlow || 0;
if (tunnel.tunnelFlow === 1) {
return outFlow; // 单向计算:只计算上传流量
} else {
return inFlow + outFlow; // 双向计算或默认:计算上传和下载的总流量
}
// 后端已按计费类型处理流量,前端直接使用入站+出站总和
return inFlow + outFlow;
};
export default function UserPage() {