diff --git a/dashboard/src2/components/ObjectListCell.vue b/dashboard/src2/components/ObjectListCell.vue
index 83931bf..7eb1915 100644
--- a/dashboard/src2/components/ObjectListCell.vue
+++ b/dashboard/src2/components/ObjectListCell.vue
@@ -41,7 +41,7 @@
- {{ value ? $dayjs(value).fromNow() : '' }}
+ {{ value ? (column.format ? formattedValue : $dayjs(value).fromNow()) : '' }}
diff --git a/dashboard/src2/components/site/SiteJobs.vue b/dashboard/src2/components/site/SiteJobs.vue
index 318d830..ba62eb4 100644
--- a/dashboard/src2/components/site/SiteJobs.vue
+++ b/dashboard/src2/components/site/SiteJobs.vue
@@ -7,6 +7,46 @@ import { isMobile } from '../../utils/device';
import { duration } from '../../utils/format';
import ObjectList from '../ObjectList.vue';
+// 英文 job_type 到中文的映射
+const jobTypeI18nMap = {
+ 'Update Site Status': '更新站点状态',
+ 'Update Site Configuration': '更新站点配置',
+ 'Install App on Site': '安装应用到站点',
+ 'Uninstall App from Site': '从站点卸载应用',
+ 'Backup Site': '备份站点',
+ 'Restore Site': '恢复站点',
+ 'Create Server': '创建服务器',
+ 'Update In Place': '原地升级',
+ // 可按需补充更多
+};
+function jobTypeI18n(type) {
+ return jobTypeI18nMap[type] || type;
+}
+
+// 状态映射
+const statusI18nMap = {
+ 'Pending': '待处理',
+ 'Running': '运行中',
+ 'Success': '成功',
+ 'Failure': '失败',
+};
+function statusI18n(status) {
+ return statusI18nMap[status] || status;
+}
+
+// 中文时间格式化
+function formatTimeZh(time) {
+ if (!time) return '';
+ const date = typeof time === 'string' ? new Date(time) : time;
+ const now = new Date();
+ const diff = (now.getTime() - date.getTime()) / 1000;
+ if (diff < 60) return '刚刚';
+ if (diff < 3600) return Math.floor(diff / 60) + '分钟前';
+ if (diff < 86400) return Math.floor(diff / 3600) + '小时前';
+ if (diff < 2592000) return Math.floor(diff / 86400) + '天前';
+ return date.toLocaleDateString('zh-CN');
+}
+
export default {
name: 'SiteJobs',
props: ['name'],
@@ -61,22 +101,15 @@ export default {
{
label: '任务类型',
fieldname: 'job_type',
- class: 'font-medium'
+ class: 'font-medium',
+ format: jobTypeI18n
},
{
label: '状态',
fieldname: 'status',
type: 'Badge',
width: 0.5,
- format(value) {
- const statusMap = {
- 'Pending': '待处理',
- 'Running': '运行中',
- 'Success': '成功',
- 'Failure': '失败'
- };
- return statusMap[value] || value;
- }
+ format: statusI18n
},
{
label: '站点',
@@ -102,7 +135,8 @@ export default {
fieldname: 'creation',
type: 'Timestamp',
width: 0.5,
- align: 'right'
+ align: 'right',
+ format: formatTimeZh
}
].filter(c => (c.condition ? c.condition() : true))
};
diff --git a/dashboard/src2/objects/common/jobs.ts b/dashboard/src2/objects/common/jobs.ts
index 4e9153f..8be680f 100644
--- a/dashboard/src2/objects/common/jobs.ts
+++ b/dashboard/src2/objects/common/jobs.ts
@@ -7,6 +7,34 @@ import { ColumnField, Tab } from './types';
type JobDocTypes = 'Site' | 'Bench' | 'Server' | 'Release Group';
+// 英文 job_type 到中文的映射
+const jobTypeI18nMap: Record