feat: add traffic limit rules and user traffic statistics

This commit is contained in:
EUForest
2026-03-14 17:59:27 +08:00
parent eac7b27f60
commit f8fbf5529f
23 changed files with 823 additions and 50 deletions
+13
View File
@@ -2693,8 +2693,13 @@ declare namespace API {
description: string;
sort: number;
for_calculation: boolean;
is_expired_group: boolean;
expired_days_limit: number;
max_traffic_gb_expired?: number;
speed_limit: number;
min_traffic_gb?: number;
max_traffic_gb?: number;
node_count?: number;
created_at: number;
updated_at: number;
};
@@ -2832,6 +2837,10 @@ declare namespace API {
description?: string;
sort?: number;
for_calculation?: boolean;
is_expired_group?: boolean;
expired_days_limit?: number;
max_traffic_gb_expired?: number;
speed_limit?: number;
min_traffic_gb?: number;
max_traffic_gb?: number;
};
@@ -2842,6 +2851,10 @@ declare namespace API {
description?: string;
sort?: number;
for_calculation?: boolean;
is_expired_group?: boolean;
expired_days_limit?: number;
max_traffic_gb_expired?: number;
speed_limit?: number;
min_traffic_gb?: number;
max_traffic_gb?: number;
};
+2
View File
@@ -9,6 +9,7 @@ import * as payment from "./payment";
import * as portal from "./portal";
import * as subscribe from "./subscribe";
import * as ticket from "./ticket";
import * as traffic from "./traffic";
import * as user from "./user";
export default {
announcement,
@@ -18,5 +19,6 @@ export default {
portal,
subscribe,
ticket,
traffic,
user,
};
+37
View File
@@ -0,0 +1,37 @@
import request from "@workspace/ui/lib/request";
export interface GetUserTrafficStatsRequest {
user_subscribe_id: string; // 保持字符串,避免精度问题
days: 7 | 30;
}
export interface DailyTrafficStats {
date: string;
upload: number;
download: number;
total: number;
}
export interface GetUserTrafficStatsResponse {
list: DailyTrafficStats[];
total_upload: number;
total_download: number;
total_traffic: number;
}
/** Get User Traffic Statistics GET /v1/public/user/traffic_stats */
export async function getUserTrafficStats(
params: GetUserTrafficStatsRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: GetUserTrafficStatsResponse }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/public/user/traffic_stats`,
{
method: "GET",
params: {
...params,
},
...(options || {}),
}
);
}
+1
View File
@@ -1184,6 +1184,7 @@ declare namespace API {
type UserSubscribe = {
id: number;
id_str: string;
user_id: number;
order_id: number;
subscribe_id: number;