From 05d98dd5769159dad9876da1242f975bbb2f7184 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 8 Jul 2026 22:22:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20SignalScout=20=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=B7=A5=E4=BD=9C=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/routes.py | 9 +- app/ui/__init__.py | 1 + app/ui/home.py | 530 +++++++++++++++++++++++++++++++++++++++ tests/test_api_health.py | 10 + 4 files changed, 549 insertions(+), 1 deletion(-) create mode 100644 app/ui/__init__.py create mode 100644 app/ui/home.py diff --git a/app/api/routes.py b/app/api/routes.py index 5e6557a..0e187d1 100644 --- a/app/api/routes.py +++ b/app/api/routes.py @@ -4,7 +4,7 @@ from datetime import date from typing import Optional from fastapi import APIRouter, Depends -from fastapi.responses import StreamingResponse +from fastapi.responses import HTMLResponse, StreamingResponse from sqlalchemy import select from sqlalchemy.orm import Session @@ -22,10 +22,17 @@ from app.schemas.agent import ( TopicCreate, TopicRead, ) +from app.ui.home import HOME_PAGE_HTML router = APIRouter() +@router.get("/", response_class=HTMLResponse) +def home() -> HTMLResponse: + # 根路径返回业务工作台,避免用户直接打开域名时看到接口404。 + return HTMLResponse(HOME_PAGE_HTML) + + @router.get("/health") def health(settings: Settings = Depends(get_settings)) -> dict: # 健康检查只返回服务身份,避免暴露密钥和内部地址。 diff --git a/app/ui/__init__.py b/app/ui/__init__.py new file mode 100644 index 0000000..ef055e2 --- /dev/null +++ b/app/ui/__init__.py @@ -0,0 +1 @@ +"""业务用户界面页面。""" diff --git a/app/ui/home.py b/app/ui/home.py new file mode 100644 index 0000000..685346a --- /dev/null +++ b/app/ui/home.py @@ -0,0 +1,530 @@ +HOME_PAGE_HTML = """ + + + + + + SignalScout + + + +
+ + +
+
+
+

今日 AI 情报

+

聚合最新新闻和开源热度,由 Agent 统一筛选、去重和生成日报。

+
+
+ +
+
+ +
+
+
+

情报信号

+ 0 条 +
+
+
正在读取情报。
+
+
+ +
+
+
+

最新日报

+ 待生成 +
+
正在读取日报。
+
+ +
+
+

最近运行

+ 0 次 +
+
+
正在读取运行记录。
+
+
+
+
+
+
+ +
+ + + + +""" diff --git a/tests/test_api_health.py b/tests/test_api_health.py index 653ea30..7b5873e 100644 --- a/tests/test_api_health.py +++ b/tests/test_api_health.py @@ -11,3 +11,13 @@ def test_health_endpoint_returns_app_identity() -> None: assert response.status_code == 200 assert response.json()["status"] == "ok" assert response.json()["app"] == "SignalScout" + + +def test_home_page_returns_dashboard_shell() -> None: + # 根路径应该展示业务工作台,而不是返回接口404。 + with TestClient(create_app()) as client: + response = client.get("/") + + assert response.status_code == 200 + assert "SignalScout" in response.text + assert "今日 AI 情报" in response.text