From eb472d232e83903162e71f9b872e89a53104387e Mon Sep 17 00:00:00 2001 From: Yuzhiran Dev Date: Sun, 17 May 2026 17:01:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=AA=E8=A1=A8=E7=9B=98=E6=A6=82?= =?UTF-8?q?=E8=A7=88=E6=A0=87=E9=A2=98=E9=A2=9C=E8=89=B2=E8=BF=87=E6=B5=85?= =?UTF-8?q?=E6=94=B9=E7=94=A8CSS=E5=8F=98=E9=87=8F=EF=BC=9B=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=8A=B6=E6=80=81=E5=88=97=E8=A1=A8=E4=BB=8E3?= =?UTF-8?q?=E4=B8=AA=E6=89=A9=E5=B1=95=E8=87=B36=E4=B8=AA=E4=B8=8E?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=95=B0=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/backend/app/api/system.py | 31 ++++++++++++------------------ platform/frontend/index.html | 13 +++++-------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/platform/backend/app/api/system.py b/platform/backend/app/api/system.py index a1ab64c..5d2153c 100644 --- a/platform/backend/app/api/system.py +++ b/platform/backend/app/api/system.py @@ -185,25 +185,17 @@ def get_scheduler_status(): @router.get("/modules/status", dependencies=[Depends(get_current_user)]) def get_modules_status(): today_str = date.today().isoformat() - module_logs = { - "creator": { - "key": "🤖 内容创作引擎", - "log": LOGS_DIR / f"creator_{today_str}.log", - "config_file": PROJECT_ROOT / "automation" / "data" / "outlines" / today_str, - }, - "optimizer": { - "key": "🔍 内容优化器", - "log": LOGS_DIR / f"optimizer_{today_str}.log", - "config_file": PROJECT_ROOT / "automation" / "data" / "drafts" / today_str, - }, - "collector": { - "key": "📡 内容收集器", - "log": LOGS_DIR / f"collector_{today_str}.log", - "config_file": PROJECT_ROOT / "automation" / "data", - }, + log_based: dict = { + "scheduled_collect": {"name": "📡 内容采集", "log": LOGS_DIR / f"collector_{today_str}.log"}, + "scheduled_sync": {"name": "🔄 指标同步", "log": LOGS_DIR / f"sync_{today_str}.log"}, + "scheduled_generate": {"name": "🤖 内容创作", "log": LOGS_DIR / f"creator_{today_str}.log"}, + "scheduled_optimize": {"name": "🔍 内容优化", "log": LOGS_DIR / f"optimizer_{today_str}.log"}, + "scheduled_optimize_sources": {"name": "📡 信息源优化", "log": LOGS_DIR / f"optimizer_sources_{today_str}.log"}, + "scheduled_metrics_sync": {"name": "📊 指标同步", "log": LOGS_DIR / f"metrics_sync_{today_str}.log"}, } + jobs = {j.id: j for j in scheduler.get_jobs()} modules = [] - for mod_id, cfg in module_logs.items(): + for mod_id, cfg in log_based.items(): log_file = cfg["log"] last_run = None task_count = 0 @@ -215,10 +207,11 @@ def get_modules_status(): task_count = content.count("完成") + content.count("success") + content.count("SUCCESS") total = task_count + content.count("失败") + content.count("failed") + content.count("ERROR") success_rate = round(task_count / total * 100) if total > 0 else None + status = "running" if log_file.exists() else ("idle" if mod_id in jobs else "stopped") modules.append({ "id": mod_id, - "title": cfg["key"], - "status": "running" if log_file.exists() else "stopped", + "title": cfg["name"], + "status": status, "last_run": last_run or "从未运行", "task_count": task_count, "success_rate": success_rate, diff --git a/platform/frontend/index.html b/platform/frontend/index.html index c3b2f51..bfa7ba0 100644 --- a/platform/frontend/index.html +++ b/platform/frontend/index.html @@ -37,7 +37,7 @@
-

+

系统概览

@@ -80,13 +80,13 @@
-

+

模块状态 - + 定时任务: - {{ schedulerStatus }} + {{ schedulerRunning ? '运行中' : '未启动' }}

@@ -214,10 +214,7 @@ this.modules = data.modules || []; const s = data.scheduler || {}; this.schedulerRunning = s.running; - this.schedulerStatus = (s.running ? '运行中' : '未启动'); - if (s.jobs && s.jobs.length) { - this.schedulerStatus += ' · ' + s.jobs.length + ' 个任务'; - } + this.schedulerStatus = (s.running ? `运行中 · ${s.jobs ? s.jobs.length : 0} 个任务` : '未启动'); } } catch (e) { console.error('获取模块状态失败:', e);