mirror of
https://gitee.com/houhuan/TrendRadar.git
synced 2025-12-21 16:17:17 +08:00
v2.2.0
This commit is contained in:
parent
db819ac209
commit
49059c11d9
159
main.py
159
main.py
@ -15,7 +15,7 @@ import requests
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
VERSION = "2.1.2"
|
VERSION = "2.2.0"
|
||||||
|
|
||||||
|
|
||||||
# === 配置管理 ===
|
# === 配置管理 ===
|
||||||
@ -1509,6 +1509,7 @@ def render_html_content(
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>热点新闻分析</title>
|
<title>热点新闻分析</title>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js" integrity="sha512-BNaRQnYJYiPSqHHDb58B0yaPfCu+Wgds8Gp/gU33kqBtgNS4tSPHuGibyoeqMV/TJlSKda6FXzoEyYGjTe+vXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
||||||
<style>
|
<style>
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
body {
|
body {
|
||||||
@ -1534,6 +1535,33 @@ def render_html_content(
|
|||||||
color: white;
|
color: white;
|
||||||
padding: 32px 24px;
|
padding: 32px 24px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: 16px;
|
||||||
|
right: 16px;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
color: white;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
|
border-color: rgba(255, 255, 255, 0.5);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-btn:active {
|
||||||
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-title {
|
.header-title {
|
||||||
@ -1837,22 +1865,63 @@ def render_html_content(
|
|||||||
font-family: 'SF Mono', Consolas, monospace;
|
font-family: 'SF Mono', Consolas, monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
margin-top: 32px;
|
||||||
|
padding: 20px 24px;
|
||||||
|
background: #f8f9fa;
|
||||||
|
border-top: 1px solid #e5e7eb;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-content {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-link {
|
||||||
|
color: #4f46e5;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-link:hover {
|
||||||
|
color: #7c3aed;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-name {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
body { padding: 12px; }
|
body { padding: 12px; }
|
||||||
.header { padding: 24px 20px; }
|
.header { padding: 24px 20px; }
|
||||||
.content { padding: 20px; }
|
.content { padding: 20px; }
|
||||||
|
.footer { padding: 16px 20px; }
|
||||||
.header-info { grid-template-columns: 1fr; gap: 12px; }
|
.header-info { grid-template-columns: 1fr; gap: 12px; }
|
||||||
.news-header { gap: 6px; }
|
.news-header { gap: 6px; }
|
||||||
.news-content { padding-right: 45px; }
|
.news-content { padding-right: 45px; }
|
||||||
.news-item { gap: 8px; }
|
.news-item { gap: 8px; }
|
||||||
.new-item { gap: 8px; }
|
.new-item { gap: 8px; }
|
||||||
.news-number { width: 20px; height: 20px; font-size: 12px; }
|
.news-number { width: 20px; height: 20px; font-size: 12px; }
|
||||||
|
.save-btn {
|
||||||
|
position: static;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
display: block;
|
||||||
|
width: fit-content;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
|
<button class="save-btn" onclick="saveAsImage()">保存为图片</button>
|
||||||
<div class="header-title">热点新闻分析</div>
|
<div class="header-title">热点新闻分析</div>
|
||||||
<div class="header-info">
|
<div class="header-info">
|
||||||
<div class="info-item">
|
<div class="info-item">
|
||||||
@ -2082,7 +2151,95 @@ def render_html_content(
|
|||||||
|
|
||||||
html += """
|
html += """
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
<div class="footer-content">
|
||||||
|
由 <span class="project-name">TrendRadar</span> 生成 ·
|
||||||
|
<a href="https://github.com/sansan0/TrendRadar" target="_blank" class="footer-link">
|
||||||
|
GitHub 开源项目
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
async function saveAsImage() {
|
||||||
|
const button = document.querySelector('.save-btn');
|
||||||
|
const originalText = button.textContent;
|
||||||
|
|
||||||
|
try {
|
||||||
|
button.textContent = '生成中...';
|
||||||
|
button.disabled = true;
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
|
||||||
|
// 等待页面稳定
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 200));
|
||||||
|
|
||||||
|
// 截图前隐藏按钮
|
||||||
|
button.style.visibility = 'hidden';
|
||||||
|
|
||||||
|
// 再次等待确保按钮完全隐藏
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
|
||||||
|
const container = document.querySelector('.container');
|
||||||
|
|
||||||
|
// 获取容器的精确位置和尺寸
|
||||||
|
const rect = container.getBoundingClientRect();
|
||||||
|
const computedStyle = window.getComputedStyle(container);
|
||||||
|
|
||||||
|
const canvas = await html2canvas(container, {
|
||||||
|
backgroundColor: '#ffffff',
|
||||||
|
scale: 1.5,
|
||||||
|
useCORS: true,
|
||||||
|
allowTaint: false,
|
||||||
|
imageTimeout: 10000,
|
||||||
|
removeContainer: false,
|
||||||
|
foreignObjectRendering: false,
|
||||||
|
logging: false,
|
||||||
|
width: container.offsetWidth,
|
||||||
|
height: container.offsetHeight,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
scrollX: 0,
|
||||||
|
scrollY: 0,
|
||||||
|
windowWidth: window.innerWidth,
|
||||||
|
windowHeight: window.innerHeight
|
||||||
|
});
|
||||||
|
|
||||||
|
button.style.visibility = 'visible';
|
||||||
|
|
||||||
|
const link = document.createElement('a');
|
||||||
|
const now = new Date();
|
||||||
|
const filename = `TrendRadar_热点新闻分析_${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}_${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}.png`;
|
||||||
|
|
||||||
|
link.download = filename;
|
||||||
|
link.href = canvas.toDataURL('image/png', 1.0);
|
||||||
|
|
||||||
|
// 触发下载
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
|
||||||
|
button.textContent = '保存成功!';
|
||||||
|
setTimeout(() => {
|
||||||
|
button.textContent = originalText;
|
||||||
|
button.disabled = false;
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
button.style.visibility = 'visible';
|
||||||
|
button.textContent = '保存失败';
|
||||||
|
setTimeout(() => {
|
||||||
|
button.textContent = originalText;
|
||||||
|
button.disabled = false;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|||||||
20
readme.md
20
readme.md
@ -7,7 +7,7 @@
|
|||||||
[](https://github.com/sansan0/TrendRadar/stargazers)
|
[](https://github.com/sansan0/TrendRadar/stargazers)
|
||||||
[](https://github.com/sansan0/TrendRadar/network/members)
|
[](https://github.com/sansan0/TrendRadar/network/members)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](https://github.com/sansan0/TrendRadar)
|
[](https://github.com/sansan0/TrendRadar)
|
||||||
|
|
||||||
[](https://work.weixin.qq.com/)
|
[](https://work.weixin.qq.com/)
|
||||||
[](https://telegram.org/)
|
[](https://telegram.org/)
|
||||||
@ -25,7 +25,7 @@
|
|||||||
> 遇到问题提 issues,或【硅基茶水间】公众号留言
|
> 遇到问题提 issues,或【硅基茶水间】公众号留言
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>👉 点击查看<strong>致谢名单</strong> (当前 <strong>🔥18🔥</strong> 位)</summary>
|
<summary>👉 点击查看<strong>致谢名单</strong> (当前 <strong>🔥19🔥</strong> 位)</summary>
|
||||||
|
|
||||||
### 数据支持
|
### 数据支持
|
||||||
|
|
||||||
@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
| 点赞人 | 金额 | 日期 | 备注 |
|
| 点赞人 | 金额 | 日期 | 备注 |
|
||||||
| :-------------------------: | :----: | :----: | :-----------------------: |
|
| :-------------------------: | :----: | :----: | :-----------------------: |
|
||||||
|
| **昊 | 5 | 2025.9.17 | |
|
||||||
| *号 | 1 | 2025.9.15 | |
|
| *号 | 1 | 2025.9.15 | |
|
||||||
| T*T | 2 | 2025.9.15 | 点赞 |
|
| T*T | 2 | 2025.9.15 | 点赞 |
|
||||||
| *家 | 10 | 2025.9.10 | |
|
| *家 | 10 | 2025.9.10 | |
|
||||||
@ -133,7 +134,7 @@
|
|||||||
|
|
||||||
GitHub 一键 Fork 即可使用,无需编程基础。
|
GitHub 一键 Fork 即可使用,无需编程基础。
|
||||||
|
|
||||||
> 30秒部署: GitHub Pages(网页浏览)
|
> 30秒部署: GitHub Pages(网页浏览)支持一键保存成图片,随时分享给他人
|
||||||
>
|
>
|
||||||
> 1分钟部署: 企业微信(手机通知)
|
> 1分钟部署: 企业微信(手机通知)
|
||||||
|
|
||||||
@ -230,14 +231,23 @@ GitHub 一键 Fork 即可使用,无需编程基础。
|
|||||||
>
|
>
|
||||||
> 下一次**新功能**,大概会是 ai 分析功能(大概(●'◡'●)
|
> 下一次**新功能**,大概会是 ai 分析功能(大概(●'◡'●)
|
||||||
|
|
||||||
### 2025/09/13 - v2.1.2
|
### 2025/09/17 - v2.2.0
|
||||||
|
|
||||||
- 解决钉钉的推送容量限制导致的新闻推送失败问题(采用分批推送)
|
- 新增一键保存新闻图片功能,让你轻松分享关注的热点
|
||||||
|
|
||||||
|
**使用说明**:
|
||||||
|
- 适用场景:当你按照教程开启了网页版功能后(GitHub Pages)
|
||||||
|
- 使用方法:用手机或电脑打开该网页链接,点击页面顶部的"保存为图片"按钮
|
||||||
|
- 实际效果:系统会自动将当前的新闻报告制作成一张精美图片,保存到你的手机相册或电脑桌面
|
||||||
|
- 分享便利:你可以直接把这张图片发给朋友、发到朋友圈,或分享到工作群,让别人也能看到你发现的重要资讯
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><strong>👉 历史更新</strong></summary>
|
<summary><strong>👉 历史更新</strong></summary>
|
||||||
|
|
||||||
|
### 2025/09/13 - v2.1.2
|
||||||
|
|
||||||
|
- 解决钉钉的推送容量限制导致的新闻推送失败问题(采用分批推送)
|
||||||
|
|
||||||
### 2025/09/04 - v2.1.1
|
### 2025/09/04 - v2.1.1
|
||||||
|
|
||||||
- 修复docker在某些架构中无法正常运行的问题
|
- 修复docker在某些架构中无法正常运行的问题
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user