Localize key status labels

This commit is contained in:
SmartUp Developer
2026-07-06 11:02:51 +08:00
parent 41ef047b6e
commit f659cc53a4
2 changed files with 23 additions and 7 deletions
+21 -6
View File
@@ -402,7 +402,7 @@
</el-table-column> </el-table-column>
<el-table-column label="状态" width="96"> <el-table-column label="状态" width="96">
<template #default="{ row }"> <template #default="{ row }">
<el-tag size="small" :type="row.status === 'import_failed' || row.status === 'failed' ? 'danger' : row.status === 'imported' ? 'success' : row.status === 'created_pending_key' ? 'warning' : 'info'"> <el-tag size="small" :type="keyStatusTagType(row.status)">
{{ keyStatusLabel(row.status) }} {{ keyStatusLabel(row.status) }}
</el-tag> </el-tag>
</template> </template>
@@ -513,10 +513,7 @@
</el-table-column> </el-table-column>
<el-table-column label="状态" width="120"> <el-table-column label="状态" width="120">
<template #default="{ row }"> <template #default="{ row }">
<el-tag v-if="row.status === 'created'" size="small" type="success">新创建</el-tag> <el-tag size="small" :type="keyStatusTagType(row.status)">{{ keyStatusLabel(row.status) }}</el-tag>
<el-tag v-else-if="row.status === 'exists'" size="small" type="info">已存在</el-tag>
<el-tag v-else-if="row.status === 'created_pending_key'" size="small" type="warning">待回填</el-tag>
<el-tag v-else size="small" type="danger">失败</el-tag>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@@ -1052,7 +1049,25 @@ function shrinkError(value: string) {
return value.length > 40 ? `${value.slice(0, 40)}` : value return value.length > 40 ? `${value.slice(0, 40)}` : value
} }
const keyStatusLabel = (s: string) => ({ created: '已创建', imported: '已导入', import_failed: '导入失败', failed: '失败', created_pending_key: '待回填' }[s] || s) const keyStatusLabel = (s: string) => ({
created: '已创建',
exists: '已存在',
imported: '已导入',
orphaned: '远端缺失',
remote: '远端存在',
replaced: '已替换',
created_pending_key: '待回填',
failed: '失败',
import_failed: '导入失败',
}[s] || '未知状态')
const keyStatusTagType = (s: string) => {
if (s === 'created' || s === 'imported') return 'success'
if (s === 'exists' || s === 'remote') return 'info'
if (s === 'orphaned' || s === 'replaced' || s === 'created_pending_key') return 'warning'
if (s === 'failed' || s === 'import_failed') return 'danger'
return 'info'
}
async function loadList() { async function loadList() {
tableLoading.value = true tableLoading.value = true
+2 -1
View File
@@ -789,7 +789,7 @@
<el-tag v-else-if="row.status === 'recreated'" size="small" type="warning">清理后重建</el-tag> <el-tag v-else-if="row.status === 'recreated'" size="small" type="warning">清理后重建</el-tag>
<el-tag v-else-if="row.status === 'exists'" size="small" type="info">已存在</el-tag> <el-tag v-else-if="row.status === 'exists'" size="small" type="info">已存在</el-tag>
<el-tag v-else-if="row.status === 'missing_key'" size="small" type="danger">缺少 Key</el-tag> <el-tag v-else-if="row.status === 'missing_key'" size="small" type="danger">缺少 Key</el-tag>
<el-tag v-else size="small" type="danger">失败</el-tag> <el-tag v-else size="small" type="danger">{{ keyStatusLabel(row.status) }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="message" label="说明/原因" min-width="150"> <el-table-column prop="message" label="说明/原因" min-width="150">
@@ -1170,6 +1170,7 @@ const syncingImportStatus = ref(false)
const reorderingPriorities = ref(false) const reorderingPriorities = ref(false)
const statusLabel = (s: string) => ({ healthy: '健康', unhealthy: '异常', unknown: '未知' }[s] || s) const statusLabel = (s: string) => ({ healthy: '健康', unhealthy: '异常', unknown: '未知' }[s] || s)
const keyStatusLabel = (s: string) => ({ created: '已创建', exists: '已存在', imported: '已导入', orphaned: '远端缺失', failed: '失败', import_failed: '导入失败', recreated: '清理后重建', missing_key: '缺少 Key' }[s] || '未知状态')
const algorithmLabel = (s: string) => ({ max_plus_percent: '最高倍率', average_plus_percent: '平均倍率', min_plus_percent: '最低倍率', priority_weighted_plus_percent: '自动保底盈利' }[s] || s) const algorithmLabel = (s: string) => ({ max_plus_percent: '最高倍率', average_plus_percent: '平均倍率', min_plus_percent: '最低倍率', priority_weighted_plus_percent: '自动保底盈利' }[s] || s)
const toUTC = (t: string) => /[Z+\-]\d*$/.test(t.trim()) ? t : t + 'Z' const toUTC = (t: string) => /[Z+\-]\d*$/.test(t.trim()) ? t : t + 'Z'
const fmtTime = (t: string) => dayjs(toUTC(t)).format('MM-DD HH:mm:ss') const fmtTime = (t: string) => dayjs(toUTC(t)).format('MM-DD HH:mm:ss')