feat(web): localize and redesign operations console

This commit is contained in:
chick
2026-07-18 22:22:41 +08:00
parent d575ab4d9d
commit abfd07f8a3
34 changed files with 1536 additions and 1058 deletions
+58
View File
@@ -0,0 +1,58 @@
export const STATUS_LABELS: Readonly<Record<string, string>> = {
online: '在线',
offline: '离线',
auth: '需要认证',
'auth-required': '需要认证',
authenticated: '已认证',
unknown: '未知',
fresh: '最新',
stale: '可能过期',
expired: '已过期',
degraded: '功能受限',
supported: '支持',
unsupported: '不支持',
queued: '排队中',
running: '运行中',
cancelling: '取消中',
cancelled: '已取消',
succeeded: '成功',
failed: '失败',
completed: '已完成',
available: '可用',
unavailable: '不可用',
idle: '空闲',
working: '工作中',
disabled: '已禁用',
enabled: '已启用',
pending: '等待中',
processing: '处理中',
healthy: '正常',
paused: '已暂停',
delivered: '已送达',
active: '活跃',
busy: '忙碌',
checking: '检查中',
'up-to-date': '已是最新',
downloading: '下载中',
verifying: '校验中',
installing: '安装中',
rebooting: '重启中',
error: '错误',
'partially-succeeded': '部分成功',
'unknown-result': '结果未知',
};
export function displayStatus(value: string): string {
return STATUS_LABELS[value] ?? value;
}
export function displayValue(value: string | number | boolean | null | undefined): string {
if (value == null) return '不可用';
if (typeof value === 'boolean') return value ? '是' : '否';
return typeof value === 'string' ? displayStatus(value) : String(value);
}
/** Transport errors are intentionally collapsed so backend free text can never expose secrets. */
export function safeUiError(_error: unknown, fallback = '操作失败,请稍后重试。'): string {
return fallback;
}