Skip to content

Commit 752ade4

Browse files
committed
add base data stats
1 parent f8001e6 commit 752ade4

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

frontend/src/components/SiteStats.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ import UserCircleIcon from "./icons/UserCircleIcon";
66
import ApiIcon from "./icons/ApiIcon";
77
import ServerIcon from "./icons/ServerIcon";
88

9+
// vmail.dev 域名的历史数据基础值
10+
const VMAIL_DEV_BASE_STATS = {
11+
totalAddressesCreated: 56023,
12+
totalEmailsReceived: 342678,
13+
totalApiKeysCreated: 1840,
14+
totalApiCalls: 15734,
15+
};
16+
17+
// 检查是否是 vmail.dev 域名
18+
function isVmailDev(): boolean {
19+
return typeof window !== "undefined" && window.location.hostname === "vmail.dev";
20+
}
21+
922
// 格式化数字,添加千分位分隔符
1023
function formatNumber(num: number): string {
1124
return num.toLocaleString();
@@ -43,7 +56,17 @@ export function SiteStats() {
4356
const fetchStats = async () => {
4457
try {
4558
const data = await getSiteStats();
46-
setStats(data);
59+
// 如果是 vmail.dev 域名,加上历史基础值
60+
if (isVmailDev()) {
61+
setStats({
62+
totalAddressesCreated: data.totalAddressesCreated + VMAIL_DEV_BASE_STATS.totalAddressesCreated,
63+
totalEmailsReceived: data.totalEmailsReceived + VMAIL_DEV_BASE_STATS.totalEmailsReceived,
64+
totalApiKeysCreated: data.totalApiKeysCreated + VMAIL_DEV_BASE_STATS.totalApiKeysCreated,
65+
totalApiCalls: data.totalApiCalls + VMAIL_DEV_BASE_STATS.totalApiCalls,
66+
});
67+
} else {
68+
setStats(data);
69+
}
4770
} catch (error) {
4871
console.error("Failed to fetch site stats:", error);
4972
} finally {

0 commit comments

Comments
 (0)