Skip to content

⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。

feat: HTML 报告浏览器增强(暗色模式/浮动工具栏/一键复制/宽屏模式/Tab导航),修复 AI 分析日志区分,升级至 v6.6.0

sansanb1d09d08ea27
diff --git a/README-EN.md b/README-EN.md
index f2dd7fc8a0..0ac22384ce 100644
--- a/README-EN.md
+++ b/README-EN.md
@@ -11,7 +11,7 @@ Deploy in <strong>30 seconds</strong> — Say goodbye to endless scrolling, only
[![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers)
[![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members)
[![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE)
-[![Version](https://img.shields.io/badge/version-v6.5.5-blue.svg)](https://github.com/sansan0/TrendRadar)
+[![Version](https://img.shields.io/badge/version-v6.6.0-blue.svg)](https://github.com/sansan0/TrendRadar)
[![MCP](https://img.shields.io/badge/MCP-v4.0.2-green.svg)](https://github.com/sansan0/TrendRadar)
[![RSS](https://img.shields.io/badge/RSS-Feed_Support-orange.svg?style=flat-square&logo=rss&logoColor=white)](https://github.com/sansan0/TrendRadar)
[![AI Translation](https://img.shields.io/badge/AI-Multi--Language-purple.svg?style=flat-square)](https://github.com/sansan0/TrendRadar)
@@ -193,20 +193,14 @@ This contributes to the sustainable maintenance of the project and the growth of
- **Tip**: Check [Changelog] to understand specific [Features]
-### 2026/03/12 - v6.5.0
-
-- **AI Smart News Filtering**: No more manual keyword setup! Describe your interests in everyday language in `ai_interests.txt` (e.g., "I want AI and renewable energy news"), and AI automatically extracts tags, scores every headline, and only pushes what truly matters to you. If AI filtering encounters issues, it auto-falls back to keyword matching — push delivery never stops
-- **Per-Period Filter Strategy & Interests**: Each time period in Timeline can now independently choose its filtering method and what topics to focus on. For example: mornings use a "tech keyword list" for quick filtering, evenings switch to "finance AI interests" for in-depth AI filtering — same system, different content at different times
-- **AI Analysis Independent from Push Mode**: AI analysis scope can differ from push content. For example: push only delivers new items (avoiding repeated notifications), while AI analyzes the full day's news (capturing complete trends). Each time period can also set its own AI analysis mode
-- **AI Filter Token Savings**: Previously analyzed news won't be re-processed; when you edit your interests, AI auto-evaluates the change magnitude — minor tweaks only update affected tags, major changes trigger full reclassification
-- **Multi-File Config & Tag Isolation**: Custom keyword files go in `config/custom/keyword/`, AI interest files go in `config/custom/ai/` — tags from different files are fully isolated and independent
-- **AI Translation Precision Control**: Independently toggle translation for hotlist, RSS, and standalone sections; regions with display turned off are automatically skipped, saving tokens
-- **Remote Storage Batch Upload**: Multiple write operations are batched and submitted to cloud in one go, reducing API call count
-- **Per-Group Display Limit**: New `max_news_per_keyword` controls max items shown per keyword/tag group, preventing a single hot topic from filling the entire push
-- **Time Period Conflict Detection**: Overlapping time periods are automatically detected — system alerts you to fix the config, preventing unexpected behavior
-- Various bug fixes
-
+### 2026/03/28 - v6.6.0
+- **HTML Report Browser Enhancement**: Open the HTML report in a browser to unlock widescreen layout, Tab navigation for keyword groups and standalone sections, real-time title search, and more — email clients still show the original narrow layout with zero regression
+- **Dark Mode**: One-click toggle for dark theme with automatic preference persistence, ideal for nighttime reading
+- **One-Click Copy**: Hover over a news number to copy the title and link instantly for quick sharing
+- **Export Optimization**: Full-page and segmented screenshots merged into a dropdown export button; screenshots auto-revert to clean layout
+- **Keyboard Shortcuts**: `W` widescreen toggle, `D` dark mode, `/` search, `?` view all shortcuts
+- **Reading Progress Bar**: Real-time reading progress displayed at the top of the page
### 2026/02/09 - mcp-v4.0.0
@@ -220,6 +214,19 @@ This contributes to the sustainable maintenance of the project and the growth of
<details>
<summary>👉 Click to expand: <strong>Historical Updates</strong></summary>
+### 2026/03/12 - v6.5.0
+
+- **AI Smart News Filtering**: No more manual keyword setup! Describe your interests in everyday language in `ai_interests.txt` (e.g., "I want AI and renewable energy news"), and AI automatically extracts tags, scores every headline, and only pushes what truly matters to you. If AI filtering encounters issues, it auto-falls back to keyword matching — push delivery never stops
+- **Per-Period Filter Strategy & Interests**: Each time period in Timeline can now independently choose its filtering method and what topics to focus on. For example: mornings use a "tech keyword list" for quick filtering, evenings switch to "finance AI interests" for in-depth AI filtering — same system, different content at different times
+- **AI Analysis Independent from Push Mode**: AI analysis scope can differ from push content. For example: push only delivers new items (avoiding repeated notifications), while AI analyzes the full day's news (capturing complete trends). Each time period can also set its own AI analysis mode
+- **AI Filter Token Savings**: Previously analyzed news won't be re-processed; when you edit your interests, AI auto-evaluates the change magnitude — minor tweaks only update affected tags, major changes trigger full reclassification
+- **Multi-File Config & Tag Isolation**: Custom keyword files go in `config/custom/keyword/`, AI interest files go in `config/custom/ai/` — tags from different files are fully isolated and independent
+- **AI Translation Precision Control**: Independently toggle translation for hotlist, RSS, and standalone sections; regions with display turned off are automatically skipped, saving tokens
+- **Remote Storage Batch Upload**: Multiple write operations are batched and submitted to cloud in one go, reducing API call count
+- **Per-Group Display Limit**: New `max_news_per_keyword` controls max items shown per keyword/tag group, preventing a single hot topic from filling the entire push
+- **Time Period Conflict Detection**: Overlapping time periods are automatically detected — system alerts you to fix the config, preventing unexpected behavior
+- Various bug fixes
+
### 2026/02/09 - v6.0.0
> **Breaking Change**: Config file upgrade (config.yaml 2.0.0), old `push_window` and `analysis_window` configs are no longer compatible, please refer to the new config.yaml for migration
@@ -1041,6 +1048,19 @@ ai_translation:
> ⚠️ Some international media content may involve sensitive topics that AI models might refuse to translate. Please filter subscription sources based on your actual needs
+### **HTML Report Browser Enhancement** (v6.6.0 New)
+
+Open the pushed HTML report in a browser to unlock an enhanced experience (email clients are unaffected):
+
+- **Widescreen Mode**: Auto-switches to 1200px wide layout on desktop, making full use of screen space
+- **Tab Navigation**: Both keyword groups and standalone sections support Tab switching — no more endless scrolling
+- **Dark Mode**: One-click dark theme toggle with automatic preference persistence
+- **Live Search**: Press `/` to open the search box and instantly filter news titles
+- **One-Click Copy**: Hover over a news number to copy the title and link
+- **Keyboard Shortcuts**: `W` widescreen, `D` dark mode, `/` search, `?` view all shortcuts
+
+> 💡 All enhancements are built on progressive enhancement — email clients still show the original 600px layout with zero regression
+
### **Flexible Storage Architecture (v4.0.0 Major Update)**
**Multi-Backend Support**:
diff --git a/README.md b/README.md
index 8a31fd8b1f..0b2b4615a5 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
[![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers)
[![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members)
[![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE)
-[![Version](https://img.shields.io/badge/version-v6.5.5-blue.svg)](https://github.com/sansan0/TrendRadar)
+[![Version](https://img.shields.io/badge/version-v6.6.0-blue.svg)](https://github.com/sansan0/TrendRadar)
[![MCP](https://img.shields.io/badge/MCP-v4.0.2-green.svg)](https://github.com/sansan0/TrendRadar)
[![RSS](https://img.shields.io/badge/RSS-订阅源支持-orange.svg?style=flat-square&logo=rss&logoColor=white)](https://github.com/sansan0/TrendRadar)
[![AI翻译](https://img.shields.io/badge/AI-多语言推送-purple.svg?style=flat-square)](https://github.com/sansan0/TrendRadar)
@@ -241,19 +241,14 @@
- **提示**:建议查看【历史更新】,明确具体的【功能内容】
-### 2026/03/12 - v6.5.0
-
-- **AI 智能筛选系统**:不用再手动设关键词!在 `ai_interests.txt` 里用日常语言写下你关注的方向(如"我想看 AI 和新能源相关新闻"),AI 会自动提取标签并对每条新闻打分,只推送真正和你相关的内容。万一 AI 筛选出了问题,会自动切回关键词匹配,推送不中断
-- **每个时段支持不同的筛选方式和关注方向**:Timeline 中的每个时间段现在可以独立设置用什么方式筛选、看什么类型的新闻。比如:早上用"科技关键词"快速过滤,晚上换成"金融 AI 兴趣描述"做深度筛选——同一个系统,不同时段看不同内容
-- **AI 分析范围独立于推送**:AI 分析的数据范围可以和推送内容不同。比如推送只发新增消息(避免重复打扰),但 AI 分析当天全部新闻(看完整趋势)。每个时段也能单独设置 AI 分析模式
-- **AI 筛选智能省钱**:已分析过的新闻不会重复消耗 token;兴趣描述修改后,AI 自动判断变化幅度——小改动只更新受影响的标签,大改动才全量重新分类
-- **多文件配置与标签隔离**:自定义关键词文件放 `config/custom/keyword/`,AI 兴趣文件放 `config/custom/ai/`,不同文件产生的标签各自独立、互不干扰
-- **AI 翻译精准控制**:可分别控制热榜、RSS、独立展示区是否翻译,没开启显示的区域自动跳过,不浪费 token
-- **远程存储批量上传**:多次写操作攒在一起统一提交云端,减少 API 调用次数
-- **每组关键词/标签展示数量限制**:通过 `max_news_per_keyword` 控制每个分组最多显示多少条新闻,避免单个热门话题占满整条推送
-- **时段冲突智能检测**:两个时间段如果有时间重叠,系统会自动报错提醒修改,避免配置冲突导致意外行为
-- 修复若干bug
+### 2026/03/28 - v6.6.0
+- **HTML 报告浏览器增强**:在浏览器中打开报告可自动切换宽屏布局,关键词分组和独立展区均支持 Tab 快速切换,搜索框实时过滤新闻标题,邮件客户端仍显示原始窄屏布局,零回归
+- **暗色模式**:一键切换深色主题,自动记住偏好,适合夜间阅读
+- **一键复制新闻**:鼠标悬停新闻序号即可复制标题和链接,方便快速分享
+- **导出优化**:整页截图和分段截图合并为下拉式导出按钮,截图时自动还原干净布局
+- **快捷键系统**:支持 `W` 宽屏切换、`D` 暗色模式、`/` 搜索、`?` 查看快捷键提示
+- **阅读进度条**:页面顶部实时显示阅读进度
### 2026/02/09 - mcp-v4.0.0
@@ -267,6 +262,19 @@
<details>
<summary>👉 点击展开:<strong>历史更新</strong></summary>
+### 2026/03/12 - v6.5.0
+
+- **AI 智能筛选系统**:不用再手动设关键词!在 `ai_interests.txt` 里用日常语言写下你关注的方向(如"我想看 AI 和新能源相关新闻"),AI 会自动提取标签并对每条新闻打分,只推送真正和你相关的内容。万一 AI 筛选出了问题,会自动切回关键词匹配,推送不中断
+- **每个时段支持不同的筛选方式和关注方向**:Timeline 中的每个时间段现在可以独立设置用什么方式筛选、看什么类型的新闻。比如:早上用"科技关键词"快速过滤,晚上换成"金融 AI 兴趣描述"做深度筛选——同一个系统,不同时段看不同内容
+- **AI 分析范围独立于推送**:AI 分析的数据范围可以和推送内容不同。比如推送只发新增消息(避免重复打扰),但 AI 分析当天全部新闻(看完整趋势)。每个时段也能单独设置 AI 分析模式
+- **AI 筛选智能省钱**:已分析过的新闻不会重复消耗 token;兴趣描述修改后,AI 自动判断变化幅度——小改动只更新受影响的标签,大改动才全量重新分类
+- **多文件配置与标签隔离**:自定义关键词文件放 `config/custom/keyword/`,AI 兴趣文件放 `config/custom/ai/`,不同文件产生的标签各自独立、互不干扰
+- **AI 翻译精准控制**:可分别控制热榜、RSS、独立展示区是否翻译,没开启显示的区域自动跳过,不浪费 token
+- **远程存储批量上传**:多次写操作攒在一起统一提交云端,减少 API 调用次数
+- **每组关键词/标签展示数量限制**:通过 `max_news_per_keyword` 控制每个分组最多显示多少条新闻,避免单个热门话题占满整条推送
+- **时段冲突智能检测**:两个时间段如果有时间重叠,系统会自动报错提醒修改,避免配置冲突导致意外行为
+- 修复若干bug
+
### 2026/02/09 - v6.0.0
> **Breaking Change**:配置文件升级(config.yaml 2.0.0),旧版 `push_window` 和 `analysis_window` 配置不再兼容,请参考新版 config.yaml 迁移
@@ -1095,6 +1103,19 @@ ai_translation:
> ⚠️ 部分海外媒体内容可能涉及敏感话题,AI 模型可能拒绝翻译,建议根据实际需求筛选订阅源
+### **HTML 报告浏览器增强**(v6.6.0 新增)
+
+在浏览器中打开推送的 HTML 报告,自动解锁增强体验(邮件客户端不受影响):
+
+- **宽屏模式**:桌面端自动切换 1200px 宽屏布局,充分利用屏幕空间
+- **Tab 快速切换**:关键词分组和独立展区均支持 Tab 导航,告别长页面翻滚
+- **暗色模式**:一键切换深色主题,自动记住偏好
+- **实时搜索**:按 `/` 唤起搜索框,即时过滤新闻标题
+- **一键复制**:悬停新闻序号即可复制标题和链接
+- **快捷键**:`W` 宽屏、`D` 暗色、`/` 搜索、`?` 查看所有快捷键
+
+> 💡 所有增强功能基于渐进增强,邮件客户端仍显示原始 600px 布局,零回归
+
### **灵活存储架构**(v4.0.0 重大更新)
**多存储后端支持**:
diff --git a/pyproject.toml b/pyproject.toml
index 5f5da9aaeb..51b6654a6c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "trendradar"
-version = "6.5.5"
+version = "6.6.0"
description = "TrendRadar - 热点新闻聚合与分析工具"
requires-python = ">=3.12"
dependencies = [
diff --git a/trendradar/__init__.py b/trendradar/__init__.py
index ebcc4da6fc..6ad1f55dd0 100644
--- a/trendradar/__init__.py
+++ b/trendradar/__init__.py
@@ -9,5 +9,5 @@ TrendRadar - 热点新闻聚合与分析工具
from trendradar.context import AppContext
-__version__ = "6.5.5"
+__version__ = "6.6.0"
__all__ = ["AppContext", "__version__"]
diff --git a/trendradar/__main__.py b/trendradar/__main__.py
index e27965a652..7a7cc39dba 100644
--- a/trendradar/__main__.py
+++ b/trendradar/__main__.py
@@ -564,6 +564,8 @@ class NewsAnalyzer:
scheduler = self.ctx.create_scheduler()
date_str = self.ctx.format_date()
scheduler.record_execution(schedule.period_key, "analyze", date_str)
+ elif result.skipped:
+ print(f"[AI] {result.error}")
else:
print(f"[AI] 分析失败: {result.error}")
diff --git a/trendradar/ai/analyzer.py b/trendradar/ai/analyzer.py
index 572e895206..715c8c5cc8 100644
--- a/trendradar/ai/analyzer.py
+++ b/trendradar/ai/analyzer.py
@@ -28,6 +28,7 @@ class AIAnalysisResult:
# 基础元数据
raw_response: str = "" # 原始响应
success: bool = False # 是否成功
+ skipped: bool = False # 是否因无内容跳过(非失败)
error: str = "" # 错误信息
# 新闻数量统计
@@ -139,7 +140,8 @@ class AIAnalyzer:
if not news_content and not rss_content:
return AIAnalysisResult(
success=False,
- error="没有可分析的新闻内容",
+ skipped=True,
+ error="本轮无新增热点内容,跳过 AI 分析",
total_news=total_news,
hotlist_count=hotlist_total,
rss_count=rss_total,
diff --git a/trendradar/ai/formatter.py b/trendradar/ai/formatter.py
index 2614a777b8..f5c5d7f68d 100644
--- a/trendradar/ai/formatter.py
+++ b/trendradar/ai/formatter.py
@@ -79,6 +79,8 @@ def _format_standalone_summaries(summaries: dict) -> str:
def render_ai_analysis_markdown(result: AIAnalysisResult) -> str:
"""渲染为通用 Markdown 格式(Telegram、企业微信、ntfy、Bark、Slack)"""
if not result.success:
+ if result.skipped:
+ return f"ℹ️ {result.error}"
return f"⚠️ AI 分析失败: {result.error}"
lines = ["**✨ AI 热点分析**", ""]
@@ -115,6 +117,8 @@ def render_ai_analysis_markdown(result: AIAnalysisResult) -> str:
def render_ai_analysis_feishu(result: AIAnalysisResult) -> str:
"""渲染为飞书卡片 Markdown 格式"""
if not result.success:
+ if result.skipped:
+ return f"ℹ️ {result.error}"
return f"⚠️ AI 分析失败: {result.error}"
lines = ["**✨ AI 热点分析**", ""]
@@ -151,6 +155,8 @@ def render_ai_analysis_feishu(result: AIAnalysisResult) -> str:
def render_ai_analysis_dingtalk(result: AIAnalysisResult) -> str:
"""渲染为钉钉 Markdown 格式"""
if not result.success:
+ if result.skipped:
+ return f"ℹ️ {result.error}"
return f"⚠️ AI 分析失败: {result.error}"
lines = ["### ✨ AI 热点分析", ""]
@@ -193,6 +199,8 @@ def render_ai_analysis_dingtalk(result: AIAnalysisResult) -> str:
def render_ai_analysis_html(result: AIAnalysisResult) -> str:
"""渲染为 HTML 格式(邮件)"""
if not result.success:
+ if result.skipped:
+ return f'<div class="ai-info">ℹ️ {_escape_html(result.error)}</div>'
return (
f'<div class="ai-error">⚠️ AI 分析失败: {_escape_html(result.error)}</div>'
)
@@ -279,6 +287,8 @@ def render_ai_analysis_html(result: AIAnalysisResult) -> str:
def render_ai_analysis_plain(result: AIAnalysisResult) -> str:
"""渲染为纯文本格式"""
if not result.success:
+ if result.skipped:
+ return result.error
return f"AI 分析失败: {result.error}"
lines = ["【✨ AI 热点分析】", ""]
@@ -316,6 +326,8 @@ def render_ai_analysis_telegram(result: AIAnalysisResult) -> str:
换行直接使用 \\n,不支持 <br>, <div>, <h1>-<h6> 等标签。
"""
if not result.success:
+ if result.skipped:
+ return f"ℹ️ {_escape_html(result.error)}"
return f"⚠️ AI 分析失败: {_escape_html(result.error)}"
lines = ["<b>✨ AI 热点分析</b>", ""]
@@ -365,6 +377,11 @@ def render_ai_analysis_html_rich(result: AIAnalysisResult) -> str:
# 检查是否成功
if not result.success:
+ if result.skipped:
+ return f"""
+ <div class="ai-section">
+ <div class="ai-info">ℹ️ {_escape_html(str(result.error))}</div>
+ </div>"""
error_msg = result.error or "未知错误"
return f"""
<div class="ai-section">
@@ -376,7 +393,8 @@ def render_ai_analysis_html_rich(result: AIAnalysisResult) -> str:
<div class="ai-section-header">
<div class="ai-section-title">✨ AI 热点分析</div>
<span class="ai-section-badge">AI</span>
- </div>"""
+ </div>
+ <div class="ai-blocks-grid">"""
if result.core_trends:
content = _format_list_content(result.core_trends)
@@ -434,5 +452,6 @@ def render_ai_analysis_html_rich(result: AIAnalysisResult) -> str:
</div>"""
ai_html += """
+ </div>
</div>"""
return ai_html
diff --git a/trendradar/report/html.py b/trendradar/report/html.py
index 9608568927..3f7e58642d 100644
--- a/trendradar/report/html.py
+++ b/trendradar/report/html.py
@@ -86,6 +86,25 @@ def render_html_content(
padding: 32px 24px;
text-align: center;
position: relative;
+ overflow: hidden;
+ }
+
+ .header-watermark {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ font-size: clamp(40px, 8vw, 80px);
+ font-weight: 900;
+ letter-spacing: 0.05em;
+ color: rgba(255, 255, 255, 0.15);
+ pointer-events: none;
+ z-index: 1;
+ white-space: nowrap;
+ -webkit-mask-image: radial-gradient(circle 0px at 50% 50%, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
+ mask-image: radial-gradient(circle 0px at 50% 50%, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%);
+ transition: -webkit-mask-image 0.3s ease, mask-image 0.3s ease;
+ user-select: none;
}
.save-buttons {
@@ -94,26 +113,32 @@ def render_html_content(
right: 16px;
display: flex;
gap: 8px;
+ z-index: 10;
+ }
+
+ .save-btn-group {
+ position: relative;
+ display: flex;
}
.save-btn {
background: rgba(255, 255, 255, 0.2);
border: 1px solid rgba(255, 255, 255, 0.3);
color: white;
- padding: 8px 16px;
- border-radius: 6px;
+ padding: 10px 18px;
+ border-radius: 6px 0 0 6px;
cursor: pointer;
font-size: 13px;
font-weight: 500;
transition: all 0.2s ease;
backdrop-filter: blur(10px);
white-space: nowrap;
+ min-height: 38px;
+ border-right: none;
}
.save-btn:hover {
background: rgba(255, 255, 255, 0.3);
- border-color: rgba(255, 255, 255, 0.5);
- transform: translateY(-1px);
}
.save-btn:active {
@@ -125,13 +150,88 @@ def render_html_content(
cursor: not-allowed;
}
+ .save-dropdown-trigger {
+ background: rgba(255, 255, 255, 0.2);
+ border: 1px solid rgba(255, 255, 255, 0.3);
+ color: white;
+ padding: 10px 10px;
+ border-radius: 0 6px 6px 0;
+ cursor: pointer;
+ font-size: 11px;
+ transition: all 0.2s ease;
+ backdrop-filter: blur(10px);
+ min-height: 38px;
+ display: flex;
+ align-items: center;
+ }
+
+ .save-dropdown-trigger:hover {
+ background: rgba(255, 255, 255, 0.35);
+ }
+
+ .save-dropdown-menu {
+ position: absolute;
+ top: 100%;
+ right: 0;
+ margin-top: 4px;
+ background: rgba(30, 30, 50, 0.92);
+ backdrop-filter: blur(16px);
+ border: 1px solid rgba(255, 255, 255, 0.15);
+ border-radius: 8px;
+ padding: 4px;
+ min-width: 140px;
+ opacity: 0;
+ visibility: hidden;
+ transform: translateY(-4px);
+ transition: all 0.2s ease;
+ box-shadow: 0 8px 24px rgba(0,0,0,0.3);
+ }
+
+ .save-btn-group:hover .save-dropdown-menu,
+ .save-dropdown-menu:hover {
+ opacity: 1;
+ visibility: visible;
+ transform: translateY(0);
+ }
+
+ .save-dropdown-item {
+ display: block;
+ width: 100%;
+ padding: 9px 14px;
+ background: none;
+ border: none;
+ color: white;
+ font-size: 13px;
+ cursor: pointer;
+ border-radius: 5px;
+ text-align: left;
+ transition: background 0.15s;
+ white-space: nowrap;
+ }
+
+ .save-dropdown-item:hover {
+ background: rgba(255, 255, 255, 0.15);
+ }
+
+ .dropdown-icon {
+ width: 14px;
+ height: 14px;
+ margin-right: 8px;
+ vertical-align: -2px;
+ flex-shrink: 0;
+ }
+
.header-title {
font-size: 22px;
font-weight: 700;
margin: 0 0 20px 0;
+ position: relative;
+ z-index: 2;
}
.header-info {
+ position: relative;
+ z-index: 2;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
@@ -246,6 +346,33 @@ def render_html_content(
justify-content: center;
align-self: flex-start;
margin-top: 8px;
+ position: relative;
+ cursor: pointer;
+ transition: background 0.15s, color 0.15s;
+ }
+ .news-number .num-text { transition: opacity 0.15s; }
+ .news-number .copy-icon {
+ position: absolute;
+ opacity: 0;
+ transition: opacity 0.15s;
+ }
+ .news-item:hover .news-number .num-text { opacity: 0; }
+ .news-item:hover .news-number .copy-icon { opacity: 1; }
+ .news-item:hover .news-number {
+ background: #eef2ff;
+ color: #4f46e5;
+ }
+ .news-number.copied {
+ background: #dcfce7 !important;
+ }
+ .news-number.copied .num-text { opacity: 0 !important; }
+ .news-number.copied .copy-icon { opacity: 1 !important; }
+ body.dark-mode .news-item:hover .news-number {
+ background: #2a2a5a;
+ color: #8ab4f8;
+ }
+ body.dark-mode .news-number.copied {
+ background: #14532d !important;
}
.news-content {
@@ -494,11 +621,14 @@ def render_html_content(
display: flex;
gap: 8px;
justify-content: center;
- flex-direction: column;
width: 100%;
}
+ .save-btn-group {
+ flex: 1;
+ }
.save-btn {
width: 100%;
+ border-radius: 6px 0 0 6px;
}
}
@@ -732,14 +862,400 @@ def render_html_content(
color: #991b1b;
font-size: 14px;
}
+
+ .ai-info {
+ padding: 16px;
+ background: #f0f9ff;
+ border: 1px solid #bae6fd;
+ border-radius: 8px;
+ color: #0369a1;
+ font-size: 14px;
+ }
+
+ /* ===== 浏览器增强样式(渐进增强,邮件客户端无影响) ===== */
+
+ /* 宽屏模式 - 基础 */
+ body.wide-mode .container { max-width: 1200px; }
+ body.wide-mode .header-info { grid-template-columns: repeat(4, 1fr); }
+ body.wide-mode .content { padding: 32px 40px; }
+
+ /* 宽屏模式 - RSS feed-group 两列 */
+ body.wide-mode .rss-feeds-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 24px;
+ }
+ body.wide-mode .feed-group { margin-bottom: 0; }
+
+ /* 宽屏模式 - AI 分析区两列网格 */
+ body.wide-mode .ai-section .ai-blocks-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 16px;
+ }
+ body.wide-mode .ai-block { margin-bottom: 0; }
+
+ /* 宽屏模式 - 新增热点多列 */
+ body.wide-mode .new-section .new-sources-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 24px;
+ }
+ body.wide-mode .new-source-group { margin-bottom: 0; }
+
+ /* 宽屏模式 - 独立展示区多列 */
+ body.wide-mode .standalone-section .standalone-groups-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 24px;
+ }
+ body.wide-mode .standalone-group { margin-bottom: 0; }
+
+ /* Tab 栏 */
+ .tab-bar {
+ display: none;
+ overflow-x: auto;
+ white-space: nowrap;
+ padding: 8px 0 12px 0;
+ margin-bottom: 20px;
+ border-bottom: 2px solid #e5e7eb;
+ -webkit-overflow-scrolling: touch;
+ scrollbar-width: thin;
+ position: sticky;
+ top: 0;
+ background: white;
+ z-index: 10;
+ gap: 4px;
+ }
+ body.wide-mode .tab-bar { display: flex; }
+ body.wide-mode .tab-bar.tab-hidden { display: none; }
+
+ .tab-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 8px 16px;
+ border: none;
+ background: #f3f4f6;
+ color: #6b7280;
+ border-radius: 8px 8px 0 0;
+ cursor: pointer;
+ font-size: 13px;
+ font-weight: 500;
+ white-space: nowrap;
+ transition: all 0.2s ease;
+ flex-shrink: 0;
+ }
+ .tab-btn:hover { background: #e5e7eb; color: #374151; }
+ .tab-btn.active { background: #4f46e5; color: white; }
+ .tab-count {
+ font-size: 11px;
+ background: rgba(0,0,0,0.1);
+ padding: 1px 6px;
+ border-radius: 10px;
+ }
+ .tab-btn.active .tab-count { background: rgba(255,255,255,0.3); }
+ .tab-bar::-webkit-scrollbar { height: 4px; }
+ .tab-bar::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 2px; }
+ .tab-bar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
+
+ /* 搜索栏 */
+ .search-bar { display: none; padding: 0 0 16px 0; }
+ .search-input {
+ width: 100%;
+ padding: 10px 16px;
+ border: 1px solid #e5e7eb;
+ border-radius: 8px;
+ font-size: 14px;
+ outline: none;
+ transition: border-color 0.2s;
+ box-sizing: border-box;
+ }
+ .search-input:focus { border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
+ .search-input::placeholder { color: #9ca3af; }
+
+ /* 右下角悬浮工具栏 */
+ .fab-bar {
+ position: fixed;
+ bottom: 24px;
+ right: 24px;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ z-index: 100;
+ opacity: 0;
+ transform: translateY(10px);
+ transition: opacity 0.3s, transform 0.3s;
+ pointer-events: none;
+ }
+ .fab-bar.visible {
+ opacity: 1;
+ transform: translateY(0);
+ pointer-events: auto;
+ }
+ .fab-btn {
+ width: 40px;
+ height: 40px;
+ border-radius: 50%;
+ background: #4f46e5;
+ color: white;
+ border: none;
+ cursor: pointer;
+ font-size: 16px;
+ box-shadow: 0 2px 8px rgba(0,0,0,0.15);
+ transition: transform 0.2s, background 0.2s;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ position: relative;
+ }
+ .fab-btn:hover { transform: scale(1.1); background: #4338ca; }
+ body.dark-mode .fab-btn { background: #533483; }
+ body.dark-mode .fab-btn:hover { background: #6d28d9; }
+
+ /* 快捷键 tooltip */
+ .fab-tooltip {
+ position: absolute;
+ bottom: 0;
+ right: 52px;
+ background: rgba(30, 30, 50, 0.92);
+ backdrop-filter: blur(12px);
+ color: white;
+ border-radius: 10px;
+ padding: 12px 16px;
+ white-space: nowrap;
+ font-size: 12px;
+ line-height: 1.8;
+ box-shadow: 0 8px 24px rgba(0,0,0,0.25);
+ border: 1px solid rgba(255,255,255,0.1);
+ opacity: 0;
+ visibility: hidden;
+ transform: translateY(6px);
+ transition: all 0.2s ease;
+ pointer-events: none;
+ }
+ .fab-btn:hover .fab-tooltip,
+ .fab-btn.show-tip .fab-tooltip {
+ opacity: 1;
+ visibility: visible;
+ transform: translateY(0);
+ pointer-events: auto;
+ }
+ .fab-tooltip .tip-row {
+ display: flex;
+ justify-content: space-between;
+ gap: 16px;
+ align-items: center;
+ }
+ .fab-tooltip .tip-key {
+ background: rgba(255,255,255,0.15);
+ border-radius: 3px;
+ padding: 1px 6px;
+ font-family: monospace;
+ font-size: 11px;
+ margin-left: 8px;
+ }
+
+ /* 折叠/展开 */
+ .collapse-icon {
+ display: none;
+ margin-right: 6px;
+ font-size: 12px;
+ color: #9ca3af;
+ transition: transform 0.2s;
+ user-select: none;
+ }
+ .word-header.collapsible { cursor: pointer; }
+ .word-header.collapsible .collapse-icon { display: inline; }
+ .word-header.collapsible:hover {
+ background: #f9fafb;
+ border-radius: 6px;
+ margin: 0 -8px 20px -8px;
+ padding: 8px;
+ }
+ .word-group.collapsed .news-item { display: none; }
+ .word-group.collapsed .collapse-icon { transform: rotate(-90deg); }
+
+ /* Tab 切换动画 */
+ body.wide-mode .word-group[data-tab-index] { animation: tabFadeIn 0.2s ease; }
+ @keyframes tabFadeIn {
+ from { opacity: 0; transform: translateY(8px); }
+ to { opacity: 1; transform: translateY(0); }
+ }
+
+ /* 宽屏切换按钮 */
+ .toggle-wide-btn {
+ background: rgba(255, 255, 255, 0.2);
+ border: 1px solid rgba(255, 255, 255, 0.3);
+ color: white;
+ padding: 10px 14px;
+ border-radius: 6px;
+ cursor: pointer;
+ font-size: 15px;
+ transition: all 0.2s ease;
+ backdrop-filter: blur(10px);
+ line-height: 1;
+ min-height: 38px;
+ }
+ .toggle-wide-btn:hover {
+ background: rgba(255, 255, 255, 0.3);
+ border-color: rgba(255, 255, 255, 0.5);
+ transform: translateY(-1px);
+ }
+
+ /* 暗色模式 */
+ body.dark-mode {
+ background: #1a1a2e;
+ color: #e0e0e0;
+ }
+ body.dark-mode .container {
+ background: #16213e;
+ box-shadow: 0 2px 16px rgba(0,0,0,0.3);
+ }
+ body.dark-mode .header {
+ background: linear-gradient(135deg, #0f3460 0%, #533483 100%);
+ }
+ body.dark-mode .content {
+ background: #16213e;
+ }
+ body.dark-mode .word-header {
+ border-bottom-color: #2a2a4a;
+ }
+ body.dark-mode .word-header.collapsible:hover {
+ background: #1a1a3e;
+ }
+ body.dark-mode .news-item {
+ border-bottom-color: #2a2a4a;
+ }
+ body.dark-mode .news-title a {
+ color: #8ab4f8;
+ }
+ body.dark-mode .news-title a:visited {
+ color: #c58af9;
+ }
+ body.dark-mode .news-meta {
+ color: #888;
+ }
+ body.dark-mode .tab-bar {
+ background: #16213e;
+ border-bottom-color: #2a2a4a;
+ }
+ body.dark-mode .tab-btn {
+ color: #aaa;
+ }
+ body.dark-mode .tab-btn.active {
+ color: #8ab4f8;
+ border-bottom-color: #8ab4f8;
+ }
+ body.dark-mode .tab-btn:hover {
+ color: #ccc;
+ background: rgba(255,255,255,0.05);
+ }
+ body.dark-mode .search-input {
+ background: #1a1a3e;
+ border-color: #2a2a4a;
+ color: #e0e0e0;
+ }
+ body.dark-mode .search-input:focus {
+ border-color: #8ab4f8;
+ }
+ /* dark fab-btn 已在 .fab-btn 中处理 */
+ body.dark-mode .footer {
+ background: #0f3460;
+ color: rgba(255,255,255,0.7);
+ }
+ body.dark-mode .rss-item,
+ body.dark-mode .new-item,
+ body.dark-mode .standalone-item {
+ border-bottom-color: #2a2a4a;
+ }
+ body.dark-mode .rss-title a,
+ body.dark-mode .new-item a,
+ body.dark-mode .standalone-item a {
+ color: #8ab4f8;
+ }
+ body.dark-mode .ai-block {
+ background: #1a1a3e;
+ border-color: #2a2a4a;
+ }
+ body.dark-mode .info-value {
+ color: white;
+ }
+
+ /* 暗色模式切换按钮 */
+ .toggle-dark-btn {
+ background: rgba(255, 255, 255, 0.2);
+ border: 1px solid rgba(255, 255, 255, 0.3);
+ color: white;
+ padding: 10px 14px;
+ border-radius: 6px;
+ cursor: pointer;
+ font-size: 15px;
+ transition: all 0.2s ease;
+ backdrop-filter: blur(10px);
+ line-height: 1;
+ min-height: 38px;
+ }
+ .toggle-dark-btn:hover {
+ background: rgba(255, 255, 255, 0.3);
+ border-color: rgba(255, 255, 255, 0.5);
+ transform: translateY(-1px);
+ }
+
+ /* 快捷键面板已集成到 fab-tooltip */
+
+ /* 阅读进度条 */
+ .reading-progress {
+ position: fixed;
+ top: 0; left: 0;
+ width: 0;
+ height: 3px;
+ background: linear-gradient(90deg, #4f46e5, #7c3aed);
+ z-index: 9999;
+ transition: width 0.1s linear;
+ }
+ body.dark-mode .reading-progress {
+ background: linear-gradient(90deg, #8ab4f8, #c58af9);
+ }
+
+ /* 复制按钮样式已集成到 .news-number */
+
+
+
+ /* 新上榜标记 */
+ .badge-new {
+ display: inline-block;
+ background: linear-gradient(135deg, #f43f5e, #ec4899);
+ color: white;
+ font-size: 10px;
+ font-weight: 600;
+ padding: 1px 6px;
+ border-radius: 3px;
+ margin-left: 6px;
+ vertical-align: middle;
+ letter-spacing: 0.5px;
+ }
+ body.dark-mode .badge-new {
+ background: linear-gradient(135deg, #be185d, #9333ea);
+ }
</style>
</head>
<body>
+ <div class="reading-progress"></div>
<div class="container">
<div class="header">
+ <div class="header-watermark">TrendRadar</div>
<div class="save-buttons">
- <button class="save-btn" onclick="saveAsImage()">保存为图片</button>
- <button class="save-btn" onclick="saveAsMultipleImages()">分段保存</button>
+ <button class="toggle-wide-btn" onclick="toggleWideMode()" title="切换宽屏/窄屏">⛶</button>
+ <button class="toggle-dark-btn" onclick="toggleDarkMode()" title="切换暗色/亮色">☽</button>
+ <div class="save-btn-group">
+ <button class="save-btn" onclick="saveAsImage()">导出</button>
+ <button class="save-dropdown-trigger">▾</button>
+ <div class="save-dropdown-menu">
+ <button class="save-dropdown-item" onclick="saveAsImage()"><svg class="dropdown-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="12" height="12" rx="2"/><circle cx="8" cy="7.5" r="2.5"/><path d="M12 4h.01"/></svg>整页截图</button>
+ <button class="save-dropdown-item" onclick="saveAsMultipleImages()"><svg class="dropdown-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1" y="4" width="10" height="10" rx="1.5"/><path d="M5 4V2.5A1.5 1.5 0 016.5 1h7A1.5 1.5 0 0115 2.5v7a1.5 1.5 0 01-1.5 1.5H12"/></svg>分段截图</button>
+ </div>
+ </div>
</div>
<div class="header-title">热点新闻分析</div>
<div class="header-info">
@@ -792,7 +1308,10 @@ def render_html_content(
</div>
</div>
- <div class="content">"""
+ <div class="content">
+ <div class="search-bar">
+ <input type="text" class="search-input" placeholder="搜索新闻标题..." oninput="handleSearch(this.value)">
+ </div>"""
# 处理失败ID错误信息
if report_data["failed_ids"]:
@@ -808,9 +1327,19 @@ def render_html_content(
# 生成热点词汇统计部分的HTML
stats_html = ""
+ tab_bar_html = ""
if report_data["stats"]:
total_count = len(report_data["stats"])
+ # 生成 Tab 栏 HTML
+ tab_bar_html = '<div class="tab-bar">'
+ for tab_i, tab_stat in enumerate(report_data["stats"]):
+ escaped_tab_word = html_escape(tab_stat["word"])
+ tab_count = tab_stat["count"]
+ tab_bar_html += f'<button class="tab-btn" data-tab-index="{tab_i}">{escaped_tab_word}<span class="tab-count">{tab_count}</span></button>'
+ tab_bar_html += '<button class="tab-btn" data-tab-index="all">全部</button>'
+ tab_bar_html += '</div>'
+
for i, stat in enumerate(report_data["stats"], 1):
count = stat["count"]
@@ -825,13 +1354,13 @@ def render_html_content(
escaped_word = html_escape(stat["word"])
stats_html += f"""
- <div class="word-group">
+ <div class="word-group" data-tab-index="{i - 1}">
<div class="word-header">
<div class="word-info">
<div class="word-name">{escaped_word}</div>
<div class="word-count {count_class}">{count} 条</div>
</div>
- <div class="word-index">{i}/{total_count}</div>
+ <div class="word-index"><span class="collapse-icon">▼</span>{i}/{total_count}</div>
</div>"""
# 处理每个词组下的新闻标题,给每条新闻标上序号
@@ -920,7 +1449,7 @@ def render_html_content(
# 给热榜统计添加外层包装
if stats_html:
stats_html = f"""
- <div class="hotlist-section">{stats_html}
+ <div class="hotlist-section">{tab_bar_html}{stats_html}
</div>"""
# 生成新增新闻区域的HTML
@@ -928,7 +1457,8 @@ def render_html_content(
if show_new_section and report_data["new_titles"]:
new_titles_html += f"""
<div class="new-section">
- <div class="new-section-title">本次新增热点 (共 {report_data['total_new_count']} 条)</div>"""
+ <div class="new-section-title">本次新增热点 (共 {report_data['total_new_count']} 条)</div>
+ <div class="new-sources-grid">"""
for source_data in report_data["new_titles"]:
escaped_source = html_escape(source_data["source_name"])
@@ -984,6 +1514,7 @@ def render_html_content(
</div>"""
new_titles_html += """
+ </div>
</div>"""
# 生成 RSS 统计内容
@@ -1025,7 +1556,8 @@ def render_html_content(
<div class="rss-section-header">
<div class="rss-section-title">{title}</div>
<div class="rss-section-count">{total_count} 条</div>
- </div>"""
+ </div>
+ <div class="rss-feeds-grid">"""
# 按关键词分组渲染(与热榜格式一致)
for stat in stats:
@@ -1082,6 +1614,7 @@ def render_html_content(
</div>"""
rss_html += """
+ </div>
</div>"""
return rss_html
@@ -1145,6 +1678,17 @@ def render_html_content(
if total_count == 0:
return ""
+ # 收集所有分组信息用于生成 tab
+ all_groups = []
+ for p in platforms:
+ items = p.get("items", [])
+ if items:
+ all_groups.append({"name": p.get("name", p.get("id", "")), "count": len(items)})
+ for f in rss_feeds:
+ items = f.get("items", [])
+ if items:
+ all_groups.append({"name": f.get("name", f.get("id", "")), "count": len(items)})
+
standalone_html = f"""
<div class="standalone-section">
<div class="standalone-section-header">
@@ -1152,6 +1696,22 @@ def render_html_content(
<div class="standalone-section-count">{total_count} 条</div>
</div>"""
+ # 生成 tab 栏(2+ 分组时)
+ if len(all_groups) >= 2:
+ standalone_html += """
+ <div class="tab-bar standalone-tab-bar">"""
+ for idx, g in enumerate(all_groups):
+ active = ' active' if idx == 0 else ''
+ standalone_html += f"""
+ <button class="tab-btn{active}" data-standalone-tab="{idx}">{html_escape(g["name"])}<span class="tab-count">{g["count"]}</span></button>"""
+ standalone_html += f"""
+ <button class="tab-btn" data-standalone-tab="all">全部<span class="tab-count">{total_count}</span></button>
+ </div>"""
+
+ standalone_html += """
+ <div class="standalone-groups-grid">"""
+
+ group_idx = 0
# 渲染热榜平台(复用 word-group 结构)
for platform in platforms:
platform_name = platform.get("name", platform.get("id", ""))
@@ -1160,7 +1720,7 @@ def render_html_content(
continue
standalone_html += f"""
- <div class="standalone-group">
+ <div class="standalone-group" data-standalone-tab="{group_idx}">
<div class="standalone-header">
<div class="standalone-name">{html_escape(platform_name)}</div>
<div class="standalone-count">{len(items)} 条</div>
@@ -1242,6 +1802,7 @@ def render_html_content(
standalone_html += """
</div>"""
+ group_idx += 1
# 渲染 RSS 源(复用相同结构)
for feed in rss_feeds:
@@ -1251,7 +1812,7 @@ def render_html_content(
continue
standalone_html += f"""
- <div class="standalone-group">
+ <div class="standalone-group" data-standalone-tab="{group_idx}">
<div class="standalone-header">
<div class="standalone-name">{html_escape(feed_name)}</div>
<div class="standalone-count">{len(items)} 条</div>
@@ -1305,8 +1866,10 @@ def render_html_content(
standalone_html += """
</div>"""
+ group_idx += 1
standalone_html += """
+ </div>
</div>"""
return standalone_html
@@ -1384,7 +1947,271 @@ def render_html_content(
</div>
</div>
+ <div class="fab-bar">
+ <button class="fab-btn" onclick="window.scrollTo({top:0,behavior:'smooth'})" title="返回顶部">↑</button>
+ <button class="fab-btn fab-help">
+ <span>?</span>
+ <div class="fab-tooltip">
+ <div class="tip-row"><span>切换宽屏</span><span class="tip-key">W</span></div>
+ <div class="tip-row"><span>暗色模式</span><span class="tip-key">D</span></div>
+ <div class="tip-row"><span>搜索</span><span class="tip-key">/</span></div>
+ <div class="tip-row"><span>上一个 Tab</span><span class="tip-key">←</span></div>
+ <div class="tip-row"><span>下一个 Tab</span><span class="tip-key">→</span></div>
+ <div class="tip-row"><span>序号可复制</span><span class="tip-key">点击</span></div>
+ </div>
+ </button>
+ </div>
+
<script>
+ // ===== 浏览器增强功能 =====
+
+ function toggleWideMode() {
+ document.body.classList.toggle('wide-mode');
+ var isWide = document.body.classList.contains('wide-mode');
+ try { localStorage.setItem('trendradar-wide-mode', isWide ? '1' : '0'); } catch(e) {}
+ var btn = document.querySelector('.toggle-wide-btn');
+ if (btn) btn.textContent = isWide ? '⊡' : '⛶';
+ initTabVisibility();
+ initCollapseVisibility();
+ initStandaloneTabVisibility();
+ }
+
+ function toggleDarkMode() {
+ var isDark = document.body.classList.toggle('dark-mode');
+ try { localStorage.setItem('trendradar-dark-mode', isDark ? '1' : '0'); } catch(e) {}
+ var btn = document.querySelector('.toggle-dark-btn');
+ if (btn) btn.textContent = isDark ? '☀' : '☽';
+ }
+
+ function initTabs() {
+ var tabBar = document.querySelector('.tab-bar');
+ if (!tabBar) return;
+ var tabs = tabBar.querySelectorAll('.tab-btn');
+ var groups = document.querySelectorAll('.word-group[data-tab-index]');
+ initTabVisibility();
+
+ function activateTab(index) {
+ tabs.forEach(function(t) { t.classList.remove('active'); });
+ if (index === 'all') {
+ var allBtn = tabBar.querySelector('[data-tab-index="all"]');
+ if (allBtn) allBtn.classList.add('active');
+ groups.forEach(function(g) { g.style.display = ''; });
+ try { history.replaceState(null, '', '#all'); } catch(e) {}
+ return;
+ }
+ var idx = parseInt(index);
+ tabs.forEach(function(t) {
+ if (parseInt(t.dataset.tabIndex) === idx) t.classList.add('active');
+ });
+ if (document.body.classList.contains('wide-mode') && !tabBar.classList.contains('tab-hidden')) {
+ groups.forEach(function(g) {
+ g.style.display = (parseInt(g.dataset.tabIndex) === idx) ? '' : 'none';
+ });
+ }
+ try { history.replaceState(null, '', '#tab-' + idx); } catch(e) {}
+ }
+
+ tabs.forEach(function(tab) {
+ tab.addEventListener('click', function() {
+ var idx = tab.dataset.tabIndex;
+ activateTab(idx === 'all' ? 'all' : parseInt(idx));
+ });
+ });
+
+ tabBar.addEventListener('keydown', function(e) {
+ if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
+ var tabsArr = Array.from(tabs);
+ var ci = tabsArr.findIndex(function(t) { return t.classList.contains('active'); });
+ var dir = e.key === 'ArrowRight' ? 1 : -1;
+ var ni = Math.max(0, Math.min(tabsArr.length - 1, ci + dir));
+ var nt = tabsArr[ni];
+ activateTab(nt.dataset.tabIndex === 'all' ? 'all' : parseInt(nt.dataset.tabIndex));
+ nt.focus();
+ e.preventDefault();
+ }
+ });
+
+ var hash = window.location.hash;
+ if (hash === '#all') { activateTab('all'); }
+ else if (hash.indexOf('#tab-') === 0) { activateTab(parseInt(hash.replace('#tab-', ''))); }
+ else { activateTab(0); }
+ }
+
+ function initTabVisibility() {
+ var tabBar = document.querySelector('.tab-bar');
+ if (!tabBar) return;
+ var groups = document.querySelectorAll('.word-group[data-tab-index]');
+ var isWide = document.body.classList.contains('wide-mode');
+ if (!isWide || groups.length <= 2) {
+ tabBar.classList.add('tab-hidden');
+ groups.forEach(function(g) { g.style.display = ''; });
+ } else {
+ tabBar.classList.remove('tab-hidden');
+ var activeTab = tabBar.querySelector('.tab-btn.active');
+ if (activeTab) { activeTab.click(); }
+ else {
+ var firstTab = tabBar.querySelector('.tab-btn');
+ if (firstTab) firstTab.click();
+ }
+ }
+ }
+
+ function handleSearch(query) {
+ query = query.toLowerCase();
+ document.querySelectorAll('.news-item').forEach(function(item) {
+ var title = (item.querySelector('.news-title') || {}).textContent || '';
+ item.style.display = (!query || title.toLowerCase().indexOf(query) !== -1) ? '' : 'none';
+ });
+ document.querySelectorAll('.rss-item').forEach(function(item) {
+ var title = (item.querySelector('.rss-title') || {}).textContent || '';
+ item.style.display = (!query || title.toLowerCase().indexOf(query) !== -1) ? '' : 'none';
+ });
+ }
+
+ function initBackToTop() {
+ var fabBar = document.querySelector('.fab-bar');
+ if (!fabBar) return;
+ window.addEventListener('scroll', function() {
+ fabBar.classList.toggle('visible', window.scrollY > 300);
+ });
+ }
+
+ function initCollapse() {
+ document.querySelectorAll('.word-header').forEach(function(header) {
+ header.addEventListener('click', function() {
+ var tabBar = document.querySelector('.tab-bar');
+ if (document.body.classList.contains('wide-mode') && tabBar && !tabBar.classList.contains('tab-hidden')) return;
+ var group = header.closest('.word-group');
+ if (group) group.classList.toggle('collapsed');
+ });
+ });
+ initCollapseVisibility();
+ }
+
+ function initCollapseVisibility() {
+ var headers = document.querySelectorAll('.word-header');
+ var tabBar = document.querySelector('.tab-bar');
+ var isTabMode = document.body.classList.contains('wide-mode') && tabBar && !tabBar.classList.contains('tab-hidden');
+ headers.forEach(function(h) {
+ if (isTabMode) { h.classList.remove('collapsible'); }
+ else { h.classList.add('collapsible'); }
+ });
+ if (isTabMode) {
+ document.querySelectorAll('.word-group.collapsed').forEach(function(g) {
+ g.classList.remove('collapsed');
+ });
+ }
+ }
+
+ // 独立展示区 Tab 切换
+ function initStandaloneTabs() {
+ var tabBar = document.querySelector('.standalone-tab-bar');
+ if (!tabBar) return;
+ var groups = document.querySelectorAll('.standalone-group[data-standalone-tab]');
+ var btns = tabBar.querySelectorAll('.tab-btn[data-standalone-tab]');
+
+ function activateStandaloneTab(val) {
+ btns.forEach(function(b) {
+ var bVal = b.getAttribute('data-standalone-tab');
+ b.classList.toggle('active', bVal === String(val));
+ });
+ groups.forEach(function(g) {
+ var gVal = g.getAttribute('data-standalone-tab');
+ g.style.display = (val === 'all' || gVal === String(val)) ? '' : 'none';
+ });
+ }
+
+ btns.forEach(function(btn) {
+ btn.addEventListener('click', function() {
+ activateStandaloneTab(btn.getAttribute('data-standalone-tab'));
+ });
+ });
+
+ // 初始状态
+ initStandaloneTabVisibility();
+ }
+
+ function initStandaloneTabVisibility() {
+ var tabBar = document.querySelector('.standalone-tab-bar');
+ if (!tabBar) return;
+ var groups = document.querySelectorAll('.standalone-group[data-standalone-tab]');
+ var isWide = document.body.classList.contains('wide-mode');
+ if (!isWide || groups.length <= 1) {
+ tabBar.classList.add('tab-hidden');
+ groups.forEach(function(g) { g.style.display = ''; });
+ } else {
+ tabBar.classList.remove('tab-hidden');
+ var activeBtn = tabBar.querySelector('.tab-btn.active');
+ if (activeBtn) activeBtn.click();
+ else { var first = tabBar.querySelector('.tab-btn'); if (first) first.click(); }
+ }
+ }
+
+ function prepareForScreenshot() {
+ var state = {
+ wasWide: document.body.classList.contains('wide-mode'),
+ hiddenGroups: []
+ };
+ document.body.classList.remove('wide-mode');
+ state.wasDark = document.body.classList.contains('dark-mode');
+ document.body.classList.remove('dark-mode');
+ document.querySelectorAll('.word-group[data-tab-index]').forEach(function(g, i) {
+ if (g.style.display === 'none') {
+ state.hiddenGroups.push(i);
+ g.style.display = '';
+ }
+ });
+ state.hiddenStandaloneGroups = [];
+ document.querySelectorAll('.standalone-group[data-standalone-tab]').forEach(function(g, i) {
+ if (g.style.display === 'none') {
+ state.hiddenStandaloneGroups.push(i);
+ g.style.display = '';
+ }
+ });
+ document.querySelectorAll('.tab-bar, .standalone-tab-bar, .search-bar, .fab-bar, .toggle-wide-btn').forEach(function(el) {
+ el.dataset.prevDisplay = el.style.display || '';
+ el.style.display = 'none';
+ });
+ document.querySelectorAll('.toggle-dark-btn').forEach(function(el) {
+ el.dataset.prevDisplay = el.style.display || ''; el.style.display = 'none';
+ });
+ document.querySelectorAll('.reading-progress').forEach(function(el) { el.style.display = 'none'; });
+ document.querySelectorAll('.header-watermark').forEach(function(el) { el.style.display = 'none'; });
+ return state;
+ }
+
+ function restoreAfterScreenshot(state) {
+ if (state.wasWide) document.body.classList.add('wide-mode');
+ if (state.wasDark) document.body.classList.add('dark-mode');
+ var groups = document.querySelectorAll('.word-group[data-tab-index]');
+ state.hiddenGroups.forEach(function(i) {
+ if (groups[i]) groups[i].style.display = 'none';
+ });
+ var standaloneGroups = document.querySelectorAll('.standalone-group[data-standalone-tab]');
+ if (state.hiddenStandaloneGroups) {
+ state.hiddenStandaloneGroups.forEach(function(i) {
+ if (standaloneGroups[i]) standaloneGroups[i].style.display = 'none';
+ });
+ }
+ document.querySelectorAll('.tab-bar, .standalone-tab-bar, .search-bar, .fab-bar, .toggle-wide-btn').forEach(function(el) {
+ el.style.display = el.dataset.prevDisplay || '';
+ delete el.dataset.prevDisplay;
+ });
+ document.querySelectorAll('.toggle-dark-btn').forEach(function(el) {
+ el.style.display = el.dataset.prevDisplay || ''; delete el.dataset.prevDisplay;
+ });
+ document.querySelectorAll('.reading-progress').forEach(function(el) { el.style.display = ''; });
+ document.querySelectorAll('.reading-progress').forEach(function(el) { el.style.display = ''; });
+ document.querySelectorAll('.header-watermark').forEach(function(el) { el.style.display = ''; });
+ initTabVisibility();
+ initCollapseVisibility();
+ initStandaloneTabVisibility();
+ var fabBar = document.querySelector('.fab-bar');
+ if (fabBar && window.scrollY > 300) fabBar.classList.add('visible');
+ }
+
+ // ===== 截图功能 =====
+
async function saveAsImage() {
const button = event.target;
const originalText = button.textContent;
@@ -1397,6 +2224,9 @@ def render_html_content(
// 等待页面稳定
await new Promise(resolve => setTimeout(resolve, 200));
+ // 截图前准备:切回窄屏布局
+ var screenshotState = prepareForScreenshot();
+
// 截图前隐藏按钮
const buttons = document.querySelector('.save-buttons');
buttons.style.visibility = 'hidden';
@@ -1426,6 +2256,7 @@ def render_html_content(
});
buttons.style.visibility = 'visible';
+ restoreAfterScreenshot(screenshotState);
const link = document.createElement('a');
const now = new Date();
@@ -1448,6 +2279,7 @@ def render_html_content(
} catch (error) {
const buttons = document.querySelector('.save-buttons');
buttons.style.visibility = 'visible';
+ restoreAfterScreenshot(screenshotState);
button.textContent = '保存失败';
setTimeout(() => {
button.textContent = originalText;
@@ -1462,6 +2294,7 @@ def render_html_content(
const container = document.querySelector('.container');
const scale = 1.5;
const maxHeight = 5000 / scale;
+ var screenshotState2 = prepareForScreenshot();
try {
button.textContent = '分析中...';
@@ -1670,6 +2503,7 @@ def render_html_content(
}
button.textContent = `已保存 ${segments.length} 张图片!`;
+ restoreAfterScreenshot(screenshotState2);
setTimeout(() => {
button.textContent = originalText;
button.disabled = false;
@@ -1679,6 +2513,7 @@ def render_html_content(
console.error('分段保存失败:', error);
const buttons = document.querySelector('.save-buttons');
buttons.style.visibility = 'visible';
+ restoreAfterScreenshot(screenshotState2);
button.textContent = '保存失败';
setTimeout(() => {
button.textContent = originalText;
@@ -1689,6 +2524,115 @@ def render_html_content(
document.addEventListener('DOMContentLoaded', function() {
window.scrollTo(0, 0);
+
+ // 自动检测宽屏模式
+ var savedMode = null;
+ try { savedMode = localStorage.getItem('trendradar-wide-mode'); } catch(e) {}
+ if (savedMode === '1' || (savedMode === null && window.innerWidth > 768)) {
+ document.body.classList.add('wide-mode');
+ var btn = document.querySelector('.toggle-wide-btn');
+ if (btn) btn.textContent = '⊡';
+ }
+
+ // 暗色模式恢复
+ var savedDark = null;
+ try { savedDark = localStorage.getItem('trendradar-dark-mode'); } catch(e) {}
+ if (savedDark === '1') {
+ document.body.classList.add('dark-mode');
+ var darkBtn = document.querySelector('.toggle-dark-btn');
+ if (darkBtn) darkBtn.textContent = '☀';
+ }
+
+ // 启用搜索栏
+ var searchBar = document.querySelector('.search-bar');
+ if (searchBar) searchBar.style.display = 'block';
+
+ // 初始化增强功能
+ initTabs();
+ initBackToTop();
+ initCollapse();
+ initStandaloneTabs();
+
+ // 键盘快捷键
+ document.addEventListener('keydown', function(e) {
+ if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
+ var helpBtn = document.querySelector('.fab-help');
+ switch(e.key) {
+ case '?':
+ if (helpBtn) {
+ helpBtn.classList.toggle('show-tip');
+ var fabBar = document.querySelector('.fab-bar');
+ if (fabBar) fabBar.classList.add('visible');
+ }
+ break;
+ case 'Escape':
+ if (helpBtn) helpBtn.classList.remove('show-tip');
+ break;
+ case 'w': case 'W': toggleWideMode(); break;
+ case 'd': case 'D': toggleDarkMode(); break;
+ case '/': e.preventDefault(); var si = document.querySelector('.search-input'); if (si) si.focus(); break;
+ }
+ });
+
+ // 阅读进度条
+ var progressBar = document.querySelector('.reading-progress');
+ if (progressBar) {
+ window.addEventListener('scroll', function() {
+ var h = document.documentElement.scrollHeight - window.innerHeight;
+ progressBar.style.width = (h > 0 ? (window.scrollY / h * 100) : 0) + '%';
+ });
+ }
+
+ // 一键复制:hover 时数字变复制图标
+ var copySvg = '<svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="5" y="5" width="9" height="9" rx="1.5"/><path d="M5 11H3.5A1.5 1.5 0 012 9.5v-7A1.5 1.5 0 013.5 1h7A1.5 1.5 0 0112 2.5V5"/></svg>';
+ var checkSvg = '<svg width="12" height="12" viewBox="0 0 16 16" fill="none" stroke="#22c55e" stroke-width="2"><path d="M3 8.5l3.5 3.5 7-7"/></svg>';
+ document.querySelectorAll('.news-item .news-number').forEach(function(numEl) {
+ var item = numEl.closest('.news-item');
+ var titleEl = item ? item.querySelector('.news-title a') : null;
+ if (!titleEl) return;
+ var numText = numEl.textContent.trim();
+ numEl.innerHTML = '<span class="num-text">' + numText + '</span><span class="copy-icon">' + copySvg + '</span>';
+ numEl.title = '点击复制标题和链接';
+ numEl.addEventListener('click', function(e) {
+ e.stopPropagation();
+ var text = titleEl.textContent.trim() + ' ' + titleEl.href;
+ navigator.clipboard.writeText(text).then(function() {
+ numEl.classList.add('copied');
+ numEl.querySelector('.copy-icon').innerHTML = checkSvg;
+ setTimeout(function() {
+ numEl.classList.remove('copied');
+ numEl.querySelector('.copy-icon').innerHTML = copySvg;
+ }, 1500);
+ });
+ });
+ });
+
+
+
+ // Header watermark 鼠标跟随揭示
+ (function() {
+ var header = document.querySelector('.header');
+ var watermark = document.querySelector('.header-watermark');
+ if (!header || !watermark) return;
+
+ var radius = 100;
+
+ header.addEventListener('mousemove', function(e) {
+ var rect = watermark.getBoundingClientRect();
+ var x = e.clientX - rect.left;
+ var y = e.clientY - rect.top;
+ var maskVal = 'radial-gradient(circle ' + radius + 'px at ' + x + 'px ' + y + 'px, rgba(0,0,0,1) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0) 100%)';
+ watermark.style.webkitMaskImage = maskVal;
+ watermark.style.maskImage = maskVal;
+ watermark.style.color = 'rgba(255, 255, 255, 0.25)';
+ });
+
+ header.addEventListener('mouseleave', function() {
+ watermark.style.webkitMaskImage = 'radial-gradient(circle 0px at 50% 50%, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%)';
+ watermark.style.maskImage = 'radial-gradient(circle 0px at 50% 50%, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%)';
+ watermark.style.color = 'rgba(255, 255, 255, 0.15)';
+ });
+ })();
});
</script>
</body>
diff --git a/uv.lock b/uv.lock
index d5846e096a..2dcd87686f 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1996,7 +1996,7 @@ wheels = [
[[package]]
name = "trendradar"
-version = "6.5.5"
+version = "6.6.0"
source = { editable = "." }
dependencies = [
{ name = "boto3" },
diff --git a/version b/version
index 0a0371ddf5..cd802a1ec4 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-6.5.5
\ No newline at end of file
+6.6.0
\ No newline at end of file