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">11-28 08:44</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">12 条</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时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://s.weibo.com/weibo?q=%23%E4%B8%AD%E5%9B%BD%E7%94%B7%E7%AF%AE%E5%AF%B9%E9%98%B5%E9%9F%A9%E5%9B%BD%E5%A4%A7%E5%90%8D%E5%8D%95%23&t=31&band_rank=2&Refer=top" 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">2</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.douyin.com/hot/2319420" 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时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.toutiao.com/trending/7577411760966893587/" 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 ">6</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://news.ifeng.com/c/8odqtPQsVL1" 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 ">7</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://news.ifeng.com/c/8ocryqC3tpx" 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 ">11</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://m.thepaper.cn/newsDetail_forward_32052238" 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">英伟达 NVIDIA 黄仁勋</div>
|
||
<div class="word-count ">4 条</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">3</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760215" target="_blank" class="news-link">“大空头 vs 英伟达”论战继续!“大空头”逐条反驳英伟达回应:不敢相信这来自全球市值最高公司</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">4</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.cls.cn/detail/2213001" target="_blank" class="news-link">一图看懂 | 谷歌TPU搅动AI“江湖”,它与英伟达GPU有何区别?</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 ">8</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760277" target="_blank" class="news-link">英伟达全员“AI化”,内部有人要求“少用AI”,黄仁勋直接发飙:“你疯了吗?”</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 ">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 top">1</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.cls.cn/detail/2213363" target="_blank" class="news-link">【早报】北京:拟将大规模AI算力搬上太空;摩根大通唱多A股</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 ">9</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760242" target="_blank" class="news-link">进军AI硬件市场!阿里夸克AI眼镜售价1899元起,搭载千问大模型、深度整合生态服务</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 ">11</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.toutiao.com/trending/7577362730961767974/" 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">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 top">1</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.zhihu.com/question/1977462001522450495" target="_blank" class="news-link">如何看待 DeepSeek 发布的新模型 DeepSeek-Math-V2?</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时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://wallstreetcn.com/articles/3760281" target="_blank" class="news-link">DeepSeek推出DeepSeekMath‑V2 模型,主攻自验证数学推理能力</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="word-group">
|
||
<div class="word-header">
|
||
<div class="word-info">
|
||
<div class="word-name">openai</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 ">6</span><span class="time-info">08时44分</span>
|
||
</div>
|
||
<div class="news-title"><a href="https://www.cls.cn/detail/2213059" target="_blank" class="news-link">OpenAI真要成“烧钱无底洞”?汇丰:到2030年仍难以盈利</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.0,当前版本 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>
|
||
|