mirror of
https://github.com/wahyd4/TrendRadar.git
synced 2026-08-08 21:05:39 +10:00
990 lines
42 KiB
HTML
990 lines
42 KiB
HTML
|
||
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<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>
|
||
* { box-sizing: border-box; }
|
||
body {
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
||
margin: 0;
|
||
padding: 16px;
|
||
background: #fafafa;
|
||
color: #333;
|
||
line-height: 1.5;
|
||
}
|
||
|
||
.container {
|
||
max-width: 600px;
|
||
margin: 0 auto;
|
||
background: white;
|
||
border-radius: 12px;
|
||
overflow: hidden;
|
||
box-shadow: 0 2px 16px rgba(0,0,0,0.06);
|
||
}
|
||
|
||
.header {
|
||
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
|
||
color: white;
|
||
padding: 32px 24px;
|
||
text-align: center;
|
||
position: relative;
|
||
}
|
||
|
||
.save-buttons {
|
||
position: absolute;
|
||
top: 16px;
|
||
right: 16px;
|
||
display: flex;
|
||
gap: 8px;
|
||
}
|
||
|
||
.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;
|
||
cursor: pointer;
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
transition: all 0.2s ease;
|
||
backdrop-filter: blur(10px);
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.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);
|
||
}
|
||
|
||
.save-btn:disabled {
|
||
opacity: 0.6;
|
||
cursor: not-allowed;
|
||
}
|
||
|
||
.header-title {
|
||
font-size: 22px;
|
||
font-weight: 700;
|
||
margin: 0 0 20px 0;
|
||
}
|
||
|
||
.header-info {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 16px;
|
||
font-size: 14px;
|
||
opacity: 0.95;
|
||
}
|
||
|
||
.info-item {
|
||
text-align: center;
|
||
}
|
||
|
||
.info-label {
|
||
display: block;
|
||
font-size: 12px;
|
||
opacity: 0.8;
|
||
margin-bottom: 4px;
|
||
}
|
||
|
||
.info-value {
|
||
font-weight: 600;
|
||
font-size: 16px;
|
||
}
|
||
|
||
.content {
|
||
padding: 24px;
|
||
}
|
||
|
||
.word-group {
|
||
margin-bottom: 40px;
|
||
}
|
||
|
||
.word-group:first-child {
|
||
margin-top: 0;
|
||
}
|
||
|
||
.word-header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
margin-bottom: 20px;
|
||
padding-bottom: 8px;
|
||
border-bottom: 1px solid #f0f0f0;
|
||
}
|
||
|
||
.word-info {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
}
|
||
|
||
.word-name {
|
||
font-size: 17px;
|
||
font-weight: 600;
|
||
color: #1a1a1a;
|
||
}
|
||
|
||
.word-count {
|
||
color: #666;
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.word-count.hot { color: #dc2626; font-weight: 600; }
|
||
.word-count.warm { color: #ea580c; font-weight: 600; }
|
||
|
||
.word-index {
|
||
color: #999;
|
||
font-size: 12px;
|
||
}
|
||
|
||
.news-item {
|
||
margin-bottom: 20px;
|
||
padding: 16px 0;
|
||
border-bottom: 1px solid #f5f5f5;
|
||
position: relative;
|
||
display: flex;
|
||
gap: 12px;
|
||
align-items: center;
|
||
}
|
||
|
||
.news-item:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.news-item.new::after {
|
||
content: "NEW";
|
||
position: absolute;
|
||
top: 12px;
|
||
right: 0;
|
||
background: #fbbf24;
|
||
color: #92400e;
|
||
font-size: 9px;
|
||
font-weight: 700;
|
||
padding: 3px 6px;
|
||
border-radius: 4px;
|
||
letter-spacing: 0.5px;
|
||
}
|
||
|
||
.news-number {
|
||
color: #999;
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
min-width: 20px;
|
||
text-align: center;
|
||
flex-shrink: 0;
|
||
background: #f8f9fa;
|
||
border-radius: 50%;
|
||
width: 24px;
|
||
height: 24px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
align-self: flex-start;
|
||
margin-top: 8px;
|
||
}
|
||
|
||
.news-content {
|
||
flex: 1;
|
||
min-width: 0;
|
||
padding-right: 40px;
|
||
}
|
||
|
||
.news-item.new .news-content {
|
||
padding-right: 50px;
|
||
}
|
||
|
||
.news-header {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
margin-bottom: 8px;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.source-name {
|
||
color: #666;
|
||
font-size: 12px;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.rank-num {
|
||
color: #fff;
|
||
background: #6b7280;
|
||
font-size: 10px;
|
||
font-weight: 700;
|
||
padding: 2px 6px;
|
||
border-radius: 10px;
|
||
min-width: 18px;
|
||
text-align: center;
|
||
}
|
||
|
||
.rank-num.top { background: #dc2626; }
|
||
.rank-num.high { background: #ea580c; }
|
||
|
||
.time-info {
|
||
color: #999;
|
||
font-size: 11px;
|
||
}
|
||
|
||
.count-info {
|
||
color: #059669;
|
||
font-size: 11px;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.news-title {
|
||
font-size: 15px;
|
||
line-height: 1.4;
|
||
color: #1a1a1a;
|
||
margin: 0;
|
||
}
|
||
|
||
.news-link {
|
||
color: #2563eb;
|
||
text-decoration: none;
|
||
}
|
||
|
||
.news-link:hover {
|
||
text-decoration: underline;
|
||
}
|
||
|
||
.news-link:visited {
|
||
color: #7c3aed;
|
||
}
|
||
|
||
.new-section {
|
||
margin-top: 40px;
|
||
padding-top: 24px;
|
||
border-top: 2px solid #f0f0f0;
|
||
}
|
||
|
||
.new-section-title {
|
||
color: #1a1a1a;
|
||
font-size: 16px;
|
||
font-weight: 600;
|
||
margin: 0 0 20px 0;
|
||
}
|
||
|
||
.new-source-group {
|
||
margin-bottom: 24px;
|
||
}
|
||
|
||
.new-source-title {
|
||
color: #666;
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
margin: 0 0 12px 0;
|
||
padding-bottom: 6px;
|
||
border-bottom: 1px solid #f5f5f5;
|
||
}
|
||
|
||
.new-item {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
padding: 8px 0;
|
||
border-bottom: 1px solid #f9f9f9;
|
||
}
|
||
|
||
.new-item:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.new-item-number {
|
||
color: #999;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
min-width: 18px;
|
||
text-align: center;
|
||
flex-shrink: 0;
|
||
background: #f8f9fa;
|
||
border-radius: 50%;
|
||
width: 20px;
|
||
height: 20px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.new-item-rank {
|
||
color: #fff;
|
||
background: #6b7280;
|
||
font-size: 10px;
|
||
font-weight: 700;
|
||
padding: 3px 6px;
|
||
border-radius: 8px;
|
||
min-width: 20px;
|
||
text-align: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.new-item-rank.top { background: #dc2626; }
|
||
.new-item-rank.high { background: #ea580c; }
|
||
|
||
.new-item-content {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.new-item-title {
|
||
font-size: 14px;
|
||
line-height: 1.4;
|
||
color: #1a1a1a;
|
||
margin: 0;
|
||
}
|
||
|
||
.error-section {
|
||
background: #fef2f2;
|
||
border: 1px solid #fecaca;
|
||
border-radius: 8px;
|
||
padding: 16px;
|
||
margin-bottom: 24px;
|
||
}
|
||
|
||
.error-title {
|
||
color: #dc2626;
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
margin: 0 0 8px 0;
|
||
}
|
||
|
||
.error-list {
|
||
list-style: none;
|
||
padding: 0;
|
||
margin: 0;
|
||
}
|
||
|
||
.error-item {
|
||
color: #991b1b;
|
||
font-size: 13px;
|
||
padding: 2px 0;
|
||
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.6;
|
||
}
|
||
|
||
.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) {
|
||
body { padding: 12px; }
|
||
.header { padding: 24px 20px; }
|
||
.content { padding: 20px; }
|
||
.footer { padding: 16px 20px; }
|
||
.header-info { grid-template-columns: 1fr; gap: 12px; }
|
||
.news-header { gap: 6px; }
|
||
.news-content { padding-right: 45px; }
|
||
.news-item { gap: 8px; }
|
||
.new-item { gap: 8px; }
|
||
.news-number { width: 20px; height: 20px; font-size: 12px; }
|
||
.save-buttons {
|
||
position: static;
|
||
margin-bottom: 16px;
|
||
display: flex;
|
||
gap: 8px;
|
||
justify-content: center;
|
||
flex-direction: column;
|
||
width: 100%;
|
||
}
|
||
.save-btn {
|
||
width: 100%;
|
||
}
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<div class="header">
|
||
<div class="save-buttons">
|
||
<button class="save-btn" onclick="saveAsImage()">保存为图片</button>
|
||
<button class="save-btn" onclick="saveAsMultipleImages()">分段保存</button>
|
||
</div>
|
||
<div class="header-title">热点新闻分析</div>
|
||
<div class="header-info">
|
||
<div class="info-item">
|
||
<span class="info-label">报告类型</span>
|
||
<span class="info-value">当日汇总</span>
|
||
</div>
|
||
<div class="info-item">
|
||
<span class="info-label">新闻总数</span>
|
||
<span class="info-value">195 条</span>
|
||
</div>
|
||
<div class="info-item">
|
||
<span class="info-label">热点新闻</span>
|
||
<span class="info-value">15 条</span>
|
||
</div>
|
||
<div class="info-item">
|
||
<span class="info-label">生成时间</span>
|
||
<span class="info-value">12-03 08:47</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="content">
|
||
<div class="word-group">
|
||
<div class="word-header">
|
||
<div class="word-info">
|
||
<div class="word-name">中国</div>
|
||
<div class="word-count hot">18 条</div>
|
||
</div>
|
||
<div class="word-index">1/6</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">1</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">凤凰网</span><span class="rank-num top">2</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://news.ifeng.com/c/8om6YWITpum" target="_blank" class="news-link">批上届政府“失职”,英国首相敦促与中国接触</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">2</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">今日头条</span><span class="rank-num top">3</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.toutiao.com/trending/7578687688339685412/" target="_blank" class="news-link">中国经济的“稳”与“进”为世界注入信心</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">3</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">澎湃新闻</span><span class="rank-num top">3</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://m.thepaper.cn/newsDetail_forward_32087130" target="_blank" class="news-link">专访|李玮锋谈中国足球:苏超给年轻人舞台,国家队仍存困难</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="word-group">
|
||
<div class="word-header">
|
||
<div class="word-info">
|
||
<div class="word-name">美国 日本 澳大利亚</div>
|
||
<div class="word-count hot">10 条</div>
|
||
</div>
|
||
<div class="word-index">2/6</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">1</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">今日头条</span><span class="rank-num top">1</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.toutiao.com/trending/7579060707275735046/" target="_blank" class="news-link">中俄就涉日本问题达成高度共识</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">2</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">澎湃新闻</span><span class="rank-num top">1</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://m.thepaper.cn/newsDetail_forward_32087362" target="_blank" class="news-link">视频丨央视曝光日本军事准备细节:研发“万能血浆”研究“处理战俘”</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">3</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">微博</span><span class="rank-num top">1</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://s.weibo.com/weibo?q=%23%E6%97%A5%E6%9C%AC%E8%87%AA%E5%8D%AB%E9%98%9F%E8%A2%AB%E6%9B%9D%E6%AD%A3%E5%9C%A8%E5%90%91%E8%A5%BF%E5%8D%97%E8%BD%AC%E7%A7%BB%23&t=31&band_rank=1&Refer=top" target="_blank" class="news-link">日本自卫队被曝正在向西南转移</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="word-group">
|
||
<div class="word-header">
|
||
<div class="word-info">
|
||
<div class="word-name">ai 人工智能</div>
|
||
<div class="word-count warm">6 条</div>
|
||
</div>
|
||
<div class="word-index">3/6</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">1</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">财联社热门</span><span class="rank-num top">2</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.cls.cn/detail/2217493" target="_blank" class="news-link">“豆包AI助手”手机售罄!生态挑战仍待破局 手机厂商或倾向于自研</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">2</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">华尔街见闻</span><span class="rank-num ">7</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760517" target="_blank" class="news-link">中国AI大战将在2026年“全面加剧”:“流量入口”成大厂“必争之地”,AI出海也将加速</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">3</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">华尔街见闻</span><span class="rank-num ">9</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760506" target="_blank" class="news-link">豆包AI助手"理想丰满现实骨感"?大摩:手机大厂更倾向自研,要落地很困难</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="word-group">
|
||
<div class="word-header">
|
||
<div class="word-info">
|
||
<div class="word-name">英伟达 NVIDIA 黄仁勋</div>
|
||
<div class="word-count ">3 条</div>
|
||
</div>
|
||
<div class="word-index">4/6</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">1</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">华尔街见闻</span><span class="rank-num high">4</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760564" target="_blank" class="news-link">亚马逊重磅发布挑战谷歌英伟达:AI芯片Trainium 3更快更节能,四款Nova 2模型,首创“开放式训练”</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">2</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">华尔街见闻</span><span class="rank-num ">10</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760498" target="_blank" class="news-link">面对谷歌的挑战,英伟达和OpenAI谁更脆弱</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">3</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">今日头条</span><span class="rank-num ">30</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.toutiao.com/trending/7579260643052621321/" target="_blank" class="news-link">谷歌的TPU要干掉英伟达吗</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="word-group">
|
||
<div class="word-header">
|
||
<div class="word-info">
|
||
<div class="word-name">DeepSeek 特斯拉</div>
|
||
<div class="word-count ">2 条</div>
|
||
</div>
|
||
<div class="word-index">5/6</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">1</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">华尔街见闻</span><span class="rank-num high">5</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760505" target="_blank" class="news-link">V3.2逼近Gemini 3,DeepSeek硬气喊话:接下来我要堆算力了</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">2</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">财联社热门</span><span class="rank-num high">5</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.cls.cn/detail/2217435" target="_blank" class="news-link">从DeepSeek“上新”看AI演进 大模型将成“全能管家”?</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="word-group">
|
||
<div class="word-header">
|
||
<div class="word-info">
|
||
<div class="word-name">iphone ipad mac ios</div>
|
||
<div class="word-count ">1 条</div>
|
||
</div>
|
||
<div class="word-index">6/6</div>
|
||
</div>
|
||
<div class="news-item ">
|
||
<div class="news-number">1</div>
|
||
<div class="news-content">
|
||
<div class="news-header">
|
||
<span class="source-name">微博</span><span class="rank-num top">2</span><span class="time-info">08时47分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://s.weibo.com/weibo?q=%23iPad%E4%B8%AD%E5%9B%BD%E5%B8%82%E5%9C%BA%E4%BB%BD%E9%A2%9D%E5%A4%A7%E8%B7%8C%23&t=31&band_rank=2&Refer=top" target="_blank" class="news-link">iPad中国市场份额大跌</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</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>
|
||
<br>
|
||
<span style="color: #ea580c; font-weight: 500;">
|
||
发现新版本 3.4.1,当前版本 3.3.0
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
async function saveAsImage() {
|
||
const button = event.target;
|
||
const originalText = button.textContent;
|
||
|
||
try {
|
||
button.textContent = '生成中...';
|
||
button.disabled = true;
|
||
window.scrollTo(0, 0);
|
||
|
||
// 等待页面稳定
|
||
await new Promise(resolve => setTimeout(resolve, 200));
|
||
|
||
// 截图前隐藏按钮
|
||
const buttons = document.querySelector('.save-buttons');
|
||
buttons.style.visibility = 'hidden';
|
||
|
||
// 再次等待确保按钮完全隐藏
|
||
await new Promise(resolve => setTimeout(resolve, 100));
|
||
|
||
const container = document.querySelector('.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
|
||
});
|
||
|
||
buttons.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) {
|
||
const buttons = document.querySelector('.save-buttons');
|
||
buttons.style.visibility = 'visible';
|
||
button.textContent = '保存失败';
|
||
setTimeout(() => {
|
||
button.textContent = originalText;
|
||
button.disabled = false;
|
||
}, 2000);
|
||
}
|
||
}
|
||
|
||
async function saveAsMultipleImages() {
|
||
const button = event.target;
|
||
const originalText = button.textContent;
|
||
const container = document.querySelector('.container');
|
||
const scale = 1.5;
|
||
const maxHeight = 5000 / scale;
|
||
|
||
try {
|
||
button.textContent = '分析中...';
|
||
button.disabled = true;
|
||
|
||
// 获取所有可能的分割元素
|
||
const newsItems = Array.from(container.querySelectorAll('.news-item'));
|
||
const wordGroups = Array.from(container.querySelectorAll('.word-group'));
|
||
const newSection = container.querySelector('.new-section');
|
||
const errorSection = container.querySelector('.error-section');
|
||
const header = container.querySelector('.header');
|
||
const footer = container.querySelector('.footer');
|
||
|
||
// 计算元素位置和高度
|
||
const containerRect = container.getBoundingClientRect();
|
||
const elements = [];
|
||
|
||
// 添加header作为必须包含的元素
|
||
elements.push({
|
||
type: 'header',
|
||
element: header,
|
||
top: 0,
|
||
bottom: header.offsetHeight,
|
||
height: header.offsetHeight
|
||
});
|
||
|
||
// 添加错误信息(如果存在)
|
||
if (errorSection) {
|
||
const rect = errorSection.getBoundingClientRect();
|
||
elements.push({
|
||
type: 'error',
|
||
element: errorSection,
|
||
top: rect.top - containerRect.top,
|
||
bottom: rect.bottom - containerRect.top,
|
||
height: rect.height
|
||
});
|
||
}
|
||
|
||
// 按word-group分组处理news-item
|
||
wordGroups.forEach(group => {
|
||
const groupRect = group.getBoundingClientRect();
|
||
const groupNewsItems = group.querySelectorAll('.news-item');
|
||
|
||
// 添加word-group的header部分
|
||
const wordHeader = group.querySelector('.word-header');
|
||
if (wordHeader) {
|
||
const headerRect = wordHeader.getBoundingClientRect();
|
||
elements.push({
|
||
type: 'word-header',
|
||
element: wordHeader,
|
||
parent: group,
|
||
top: groupRect.top - containerRect.top,
|
||
bottom: headerRect.bottom - containerRect.top,
|
||
height: headerRect.height
|
||
});
|
||
}
|
||
|
||
// 添加每个news-item
|
||
groupNewsItems.forEach(item => {
|
||
const rect = item.getBoundingClientRect();
|
||
elements.push({
|
||
type: 'news-item',
|
||
element: item,
|
||
parent: group,
|
||
top: rect.top - containerRect.top,
|
||
bottom: rect.bottom - containerRect.top,
|
||
height: rect.height
|
||
});
|
||
});
|
||
});
|
||
|
||
// 添加新增新闻部分
|
||
if (newSection) {
|
||
const rect = newSection.getBoundingClientRect();
|
||
elements.push({
|
||
type: 'new-section',
|
||
element: newSection,
|
||
top: rect.top - containerRect.top,
|
||
bottom: rect.bottom - containerRect.top,
|
||
height: rect.height
|
||
});
|
||
}
|
||
|
||
// 添加footer
|
||
const footerRect = footer.getBoundingClientRect();
|
||
elements.push({
|
||
type: 'footer',
|
||
element: footer,
|
||
top: footerRect.top - containerRect.top,
|
||
bottom: footerRect.bottom - containerRect.top,
|
||
height: footer.offsetHeight
|
||
});
|
||
|
||
// 计算分割点
|
||
const segments = [];
|
||
let currentSegment = { start: 0, end: 0, height: 0, includeHeader: true };
|
||
let headerHeight = header.offsetHeight;
|
||
currentSegment.height = headerHeight;
|
||
|
||
for (let i = 1; i < elements.length; i++) {
|
||
const element = elements[i];
|
||
const potentialHeight = element.bottom - currentSegment.start;
|
||
|
||
// 检查是否需要创建新分段
|
||
if (potentialHeight > maxHeight && currentSegment.height > headerHeight) {
|
||
// 在前一个元素结束处分割
|
||
currentSegment.end = elements[i - 1].bottom;
|
||
segments.push(currentSegment);
|
||
|
||
// 开始新分段
|
||
currentSegment = {
|
||
start: currentSegment.end,
|
||
end: 0,
|
||
height: element.bottom - currentSegment.end,
|
||
includeHeader: false
|
||
};
|
||
} else {
|
||
currentSegment.height = potentialHeight;
|
||
currentSegment.end = element.bottom;
|
||
}
|
||
}
|
||
|
||
// 添加最后一个分段
|
||
if (currentSegment.height > 0) {
|
||
currentSegment.end = container.offsetHeight;
|
||
segments.push(currentSegment);
|
||
}
|
||
|
||
button.textContent = `生成中 (0/${segments.length})...`;
|
||
|
||
// 隐藏保存按钮
|
||
const buttons = document.querySelector('.save-buttons');
|
||
buttons.style.visibility = 'hidden';
|
||
|
||
// 为每个分段生成图片
|
||
const images = [];
|
||
for (let i = 0; i < segments.length; i++) {
|
||
const segment = segments[i];
|
||
button.textContent = `生成中 (${i + 1}/${segments.length})...`;
|
||
|
||
// 创建临时容器用于截图
|
||
const tempContainer = document.createElement('div');
|
||
tempContainer.style.cssText = `
|
||
position: absolute;
|
||
left: -9999px;
|
||
top: 0;
|
||
width: ${container.offsetWidth}px;
|
||
background: white;
|
||
`;
|
||
tempContainer.className = 'container';
|
||
|
||
// 克隆容器内容
|
||
const clonedContainer = container.cloneNode(true);
|
||
|
||
// 移除克隆内容中的保存按钮
|
||
const clonedButtons = clonedContainer.querySelector('.save-buttons');
|
||
if (clonedButtons) {
|
||
clonedButtons.style.display = 'none';
|
||
}
|
||
|
||
tempContainer.appendChild(clonedContainer);
|
||
document.body.appendChild(tempContainer);
|
||
|
||
// 等待DOM更新
|
||
await new Promise(resolve => setTimeout(resolve, 100));
|
||
|
||
// 使用html2canvas截取特定区域
|
||
const canvas = await html2canvas(clonedContainer, {
|
||
backgroundColor: '#ffffff',
|
||
scale: scale,
|
||
useCORS: true,
|
||
allowTaint: false,
|
||
imageTimeout: 10000,
|
||
logging: false,
|
||
width: container.offsetWidth,
|
||
height: segment.end - segment.start,
|
||
x: 0,
|
||
y: segment.start,
|
||
windowWidth: window.innerWidth,
|
||
windowHeight: window.innerHeight
|
||
});
|
||
|
||
images.push(canvas.toDataURL('image/png', 1.0));
|
||
|
||
// 清理临时容器
|
||
document.body.removeChild(tempContainer);
|
||
}
|
||
|
||
// 恢复按钮显示
|
||
buttons.style.visibility = 'visible';
|
||
|
||
// 下载所有图片
|
||
const now = new Date();
|
||
const baseFilename = `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')}`;
|
||
|
||
for (let i = 0; i < images.length; i++) {
|
||
const link = document.createElement('a');
|
||
link.download = `${baseFilename}_part${i + 1}.png`;
|
||
link.href = images[i];
|
||
document.body.appendChild(link);
|
||
link.click();
|
||
document.body.removeChild(link);
|
||
|
||
// 延迟一下避免浏览器阻止多个下载
|
||
await new Promise(resolve => setTimeout(resolve, 100));
|
||
}
|
||
|
||
button.textContent = `已保存 ${segments.length} 张图片!`;
|
||
setTimeout(() => {
|
||
button.textContent = originalText;
|
||
button.disabled = false;
|
||
}, 2000);
|
||
|
||
} catch (error) {
|
||
console.error('分段保存失败:', error);
|
||
const buttons = document.querySelector('.save-buttons');
|
||
buttons.style.visibility = 'visible';
|
||
button.textContent = '保存失败';
|
||
setTimeout(() => {
|
||
button.textContent = originalText;
|
||
button.disabled = false;
|
||
}, 2000);
|
||
}
|
||
}
|
||
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
window.scrollTo(0, 0);
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|
||
|