重构:将 "lobster" 重命名为 "claw" 并添加国际化支持 (i18n)

This commit is contained in:
richarjiang
2026-03-13 12:07:28 +08:00
parent fa4c458eda
commit 9e30771180
38 changed files with 1003 additions and 344 deletions

View File

@@ -24,33 +24,33 @@ if (process.env.NODE_ENV !== "production") {
}
const CHANNEL_REALTIME = "channel:realtime";
const ACTIVE_LOBSTERS_KEY = "active:lobsters";
const ACTIVE_CLAWS_KEY = "active:claws";
const STATS_GLOBAL_KEY = "stats:global";
const STATS_REGION_KEY = "stats:region";
const HEATMAP_CACHE_KEY = "cache:heatmap";
const HOURLY_ACTIVITY_KEY = "stats:hourly";
export async function setLobsterOnline(
lobsterId: string,
export async function setClawOnline(
clawId: string,
ip: string
): Promise<void> {
await redis.set(`lobster:online:${lobsterId}`, ip, "EX", 300);
await redis.set(`claw:online:${clawId}`, ip, "EX", 300);
}
export async function isLobsterOnline(lobsterId: string): Promise<boolean> {
const result = await redis.exists(`lobster:online:${lobsterId}`);
export async function isClawOnline(clawId: string): Promise<boolean> {
const result = await redis.exists(`claw:online:${clawId}`);
return result === 1;
}
export async function updateActiveLobsters(lobsterId: string): Promise<void> {
export async function updateActiveClaws(clawId: string): Promise<void> {
const now = Date.now();
await redis.zadd(ACTIVE_LOBSTERS_KEY, now, lobsterId);
await redis.zadd(ACTIVE_CLAWS_KEY, now, clawId);
}
export async function getActiveLobsterIds(
export async function getActiveClawIds(
limit: number = 100
): Promise<string[]> {
return redis.zrevrange(ACTIVE_LOBSTERS_KEY, 0, limit - 1);
return redis.zrevrange(ACTIVE_CLAWS_KEY, 0, limit - 1);
}
export async function incrementRegionCount(region: string): Promise<void> {