/** 后台界面中文标签;原值可放 tooltip。 */ export const messageStateLabel: Record = { scheduled: "定时中", dispatched: "投递中", completed: "已完成", }; export const destKindLabel: Record = { endpoint: "设备端", group: "群组", }; export const deliveryStateLabel: Record = { pending: "待投递", accepted: "已收下", recalled: "已撤回", expired: "已过期", dropped: "已丢弃", rejected: "已拒绝", }; export const reasonLabel: Record = { disabled: "端已停用", expired: "已过期", recalled: "已撤回", dropped: "已丢弃", rejected: "已拒绝", unauthorized: "未授权", not_found: "不存在", }; export const settingsFieldLabel: Record = { listen: "服务端口", admin_listen: "后台端口", session_idle_days: "登录闲置天数", record_retention_days: "记录保留天数", idempotency_hours: "重复提交识别(小时)", receipt_retention_days: "回执保留天数", sqlite_synchronous: "写入确认方式", }; export const limitsLabel: Record = { max_body_bytes: "单条消息最大字节", max_meta_bytes: "附加信息最大字节", max_frame_bytes: "单帧最大字节", max_ttl_seconds: "离线保留最长时间(秒)", max_schedule_seconds: "定时最远时间(秒)", max_group_members: "群组人数上限", grace_seconds: "短暂断线宽限(秒)", ack_timeout_seconds: "等待确认(秒)", delivery_window: "同时推送条数", receipt_window: "同时等待回执条数", requests_per_second: "每秒请求上限", max_pending_per_sender: "发送方未完成上限", max_pending_per_receiver: "接收方未收下上限", }; export function zhLabel(map: Record, value: string | undefined | null, fallback = "—"): string { if (value == null || value === "") return fallback; return map[value] ?? value; } /** 运行时长:天、时、分。 */ export function formatUptime(ms: number): string { const total = Math.max(0, Math.floor(ms / 1000)); const days = Math.floor(total / 86400); const hours = Math.floor((total % 86400) / 3600); const mins = Math.floor((total % 3600) / 60); const parts: string[] = []; if (days > 0) parts.push(`${days} 天`); if (hours > 0 || days > 0) parts.push(`${hours} 小时`); parts.push(`${mins} 分`); return parts.join(" "); }