feat: 深色主题UI、错误分类、批量抓取、健康度筛选

- 修复 datetime 时区不一致导致所有API 500错误的问题
- Feeds/Dashboard 页面改为深色表格主题,高对比度文字
- 添加错误类型自动分类(URL失效/被拒绝/超时/DNS失败/SSL错误等12种)
- 新增"下次抓取时间"列,从APScheduler获取
- 新增健康度筛选下拉,修复分页后过滤失效的bug
- "全部抓取"改为同步并发执行,基于当前筛选条件获取所有匹配源
- 新增数据库自动迁移机制,处理增量列变更

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
congsh
2026-06-11 17:44:54 +08:00
parent c59dd304f7
commit 68bba3d9e0
12 changed files with 846 additions and 192 deletions
+39
View File
@@ -35,9 +35,48 @@ def init_db():
from models import Feed, Article, FetchLog # noqa
Base.metadata.create_all(bind=engine)
_migrate(engine)
init_fts5()
def _migrate(engine):
"""处理数据库增量迁移(添加新列)"""
import logging
logger = logging.getLogger(__name__)
conn = engine.raw_connection()
cursor = conn.cursor()
# 获取 feeds 表现有列
cursor.execute("PRAGMA table_info(feeds)")
existing = {row[1] for row in cursor.fetchall()}
migrations = [
("feeds", "error_type", "VARCHAR(32) DEFAULT ''"),
]
for table, column, col_type in migrations:
if column not in existing:
logger.info(f"迁移: ALTER TABLE {table} ADD COLUMN {column} {col_type}")
cursor.execute(f"ALTER TABLE {table} ADD COLUMN {column} {col_type}")
conn.commit()
# 对已有错误数据分类
from rss_fetcher import classify_error
cursor.execute("SELECT id, last_error FROM feeds WHERE last_error != '' AND (error_type IS NULL OR error_type = '')")
rows = cursor.fetchall()
for row in rows:
feed_id, error = row
etype = classify_error(error)
if etype:
cursor.execute("UPDATE feeds SET error_type = ? WHERE id = ?", (etype, feed_id))
if rows:
conn.commit()
logger.info(f"迁移: 已分类 {len(rows)} 条历史错误")
cursor.close()
conn.close()
def init_fts5():
"""初始化 FTS5 全文搜索虚拟表"""
conn = engine.raw_connection()