From e7b5a1ce0996e198e288904a0c0e31c30236cd6f Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Tue, 14 Apr 2026 10:40:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Cron=E5=88=97=E8=A1=A8=E7=A7=BB?= =?UTF-8?q?=E8=87=B3=E5=BA=95=E9=83=A8=E5=B9=B6=E6=B7=BB=E5=8A=A0=E6=A6=82?= =?UTF-8?q?=E8=BF=B0=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 143 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 114 insertions(+), 29 deletions(-) diff --git a/app.py b/app.py index e39ed75..aa8015f 100644 --- a/app.py +++ b/app.py @@ -244,7 +244,7 @@ HTML_TEMPLATE = ''' -
+
@@ -281,34 +281,6 @@ HTML_TEMPLATE = '''
-
-
-
-

系统Cron

-

-

-
- -
-
-
- - -
-
-

- - 主机 Cron 列表 -

- -
-
-
- -

加载中...

-
-
@@ -337,6 +309,33 @@ HTML_TEMPLATE = '''

加载中...

+ + +
+
+

+ + 主机 Cron 列表 + - +

+ +
+ + +
+
加载中...
+
+ + +
+
+ +

加载中...

+
+
+
@@ -686,6 +685,7 @@ HTML_TEMPLATE = ''' function renderCrons(crons) { const list = document.getElementById('cronsList'); + document.getElementById('systemCronCount').textContent = `${crons.length} 个`; if (crons.length === 0) { list.innerHTML = ` @@ -697,6 +697,54 @@ HTML_TEMPLATE = ''' return; } + // 分类统计并生成概述 + const userCrons = crons.filter(c => c.source === 'user'); + const systemCrons = crons.filter(c => c.source === 'system'); + const cronDCrons = crons.filter(c => c.source === 'cron.d'); + + // 分析用户任务用途 + const userTaskTypes = analyzeUserCrons(userCrons); + + // 生成概述 + let summaryHtml = ` +
+
+
+ + 用户任务 + ${userCrons.length} 个 +
+
+ ${userTaskTypes.map(t => `
${t.count}个 ${t.name}
`).join('')} +
+
+
+
+ + 系统任务 + ${systemCrons.length} 个 +
+
+
每小时 执行 cron.hourly
+
每天 执行 cron.daily
+
每周 执行 cron.weekly
+
每月 执行 cron.monthly
+
+
+
+
+ + cron.d + ${cronDCrons.length} 个 +
+
+ ${cronDCrons.map(c => `
${c.file} ${c.description || ''}
`).join('')} +
+
+
+ `; + document.getElementById('cronSummary').innerHTML = summaryHtml; + const sourceColors = { 'user': { bg: 'bg-blue-500/20', text: 'text-blue-400', label: '用户' }, 'system': { bg: 'bg-red-500/20', text: 'text-red-400', label: '系统' }, @@ -735,6 +783,43 @@ HTML_TEMPLATE = ''' list.innerHTML = html; } + function analyzeUserCrons(crons) { + const types = []; + + // 服务监控 + const monitors = crons.filter(c => c.command.includes('service-monitor') || c.command.includes('monitor.py') || c.command.includes('cpu-monitor') || c.command.includes('disk-monitor')); + if (monitors.length > 0) types.push({ name: '系统监控', count: monitors.length }); + + // 股票/板块相关 + const stocks = crons.filter(c => c.command.includes('stock') || c.command.includes('board_monitor')); + if (stocks.length > 0) types.push({ name: 'A股数据/板块监控', count: stocks.length }); + + // 每日总结 + const summaries = crons.filter(c => c.command.includes('daily-summary') || c.command.includes('summary')); + if (summaries.length > 0) types.push({ name: '每日总结', count: summaries.length }); + + // 清理脚本 + const cleanups = crons.filter(c => c.command.includes('cleanup') || c.command.includes('clean')); + if (cleanups.length > 0) types.push({ name: '清理脚本', count: cleanups.length }); + + // 其他 + const others = crons.filter(c => + !c.command.includes('service-monitor') && + !c.command.includes('monitor.py') && + !c.command.includes('cpu-monitor') && + !c.command.includes('disk-monitor') && + !c.command.includes('stock') && + !c.command.includes('board_monitor') && + !c.command.includes('daily-summary') && + !c.command.includes('summary') && + !c.command.includes('cleanup') && + !c.command.includes('clean') + ); + if (others.length > 0) types.push({ name: '其他任务', count: others.length }); + + return types; + } + function escapeHtml(text) { const div = document.createElement('div'); div.textContent = text;