更新日志页面和统计页面

- 更新 LogsPage 和 StatsPage 组件
- 添加 taskSource 工具模块
- 更新 db/tasks.py
- 重新构建前端静态资源
This commit is contained in:
2025-12-15 16:25:37 +08:00
parent a8b9f225bd
commit 49897081b6
25 changed files with 118 additions and 65 deletions

View File

@@ -0,0 +1,43 @@
function normalizeRawSource(source) {
return String(source || '').trim()
}
function getBatchIdFromUserScheduledSource(raw) {
if (!raw.startsWith('user_scheduled')) return ''
if (!raw.includes(':')) return ''
return raw.split(':', 2)[1] || ''
}
export function getTaskSourceMeta(source) {
const raw = normalizeRawSource(source)
if (!raw || raw === 'manual') {
return { group: 'manual', label: '手动', type: 'success', tooltip: '' }
}
if (raw === 'scheduled') {
return { group: 'scheduled', label: '定时任务', type: 'primary', tooltip: '系统定时' }
}
if (raw.startsWith('user_scheduled')) {
const batchId = getBatchIdFromUserScheduledSource(raw)
const batchShort = String(batchId || '').replace(/^batch_/, '')
return {
group: 'scheduled',
label: '定时任务',
type: 'primary',
tooltip: batchShort ? `用户定时批次:${batchShort}` : '用户定时',
}
}
const manualTips = {
batch: '手动批量',
manual_screenshot: '手动截图',
immediate: '立即执行',
resumed: '断点恢复',
}
const tip = manualTips[raw] || raw
return { group: 'manual', label: '手动', type: 'success', tooltip: tip }
}