generated from sansan0/TrendRadar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
747 lines (651 loc) · 26.2 KB
/
index.html
File metadata and controls
747 lines (651 loc) · 26.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
<!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-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;
}
.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;
}
.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-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">387 条</span>
</div>
<div class="info-item">
<span class="info-label">热点新闻</span>
<span class="info-value">5 条</span>
</div>
<div class="info-item">
<span class="info-label">生成时间</span>
<span class="info-value">06-16 07:17</span>
</div>
</div>
</div>
<div class="content">
<div class="word-group">
<div class="word-header">
<div class="word-info">
<div class="word-name">ai 人工智能</div>
<div class="word-count hot">3 条</div>
</div>
<div class="word-index">1/4</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">7-8</span>
<span class="time-info">00:23~07:17</span>
<span class="count-info">15次</span>
</div>
<div class="news-title">
<a href="https://www.cls.cn/detail/2057563" target="_blank" class="news-link">上市首日暴涨140% 军用无人机公司登陆纽交所 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">tieba</span>
<span class="rank-num">18-19</span>
<span class="time-info">00:23~07:17</span>
<span class="count-info">15次</span>
</div>
<div class="news-title">
<a href="https://tieba.baidu.com/hottopic/browse/hottopic?topic_id=28342819&topic_name=%E4%BC%8A%E6%9C%97%E7%96%91%E7%94%A8AI%E4%BC%AA%E9%80%A0%E4%BB%A5%E5%86%9BF35%E6%AE%8B%E9%AA%B8%E5%9B%BE" target="_blank" class="news-link">伊朗疑用AI伪造以军F35残骸图</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">zhihu</span>
<span class="rank-num top">5-13</span>
<span class="time-info">00:23~07:17</span>
<span class="count-info">15次</span>
</div>
<div class="news-title">
<a href="https://www.zhihu.com/question/596907281" 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">1 条</div>
</div>
<div class="word-index">2/4</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">8-9</span>
<span class="time-info">00:23~07:17</span>
<span class="count-info">15次</span>
</div>
<div class="news-title">
<a href="https://wallstreetcn.com/articles/3749141" target="_blank" class="news-link">恒生生科指数1月以来涨超60%,中国创新药的"DeepSeek时刻"超过了AI</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">1 条</div>
</div>
<div class="word-index">3/4</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">24-30</span>
<span class="time-info">00:57~06:55</span>
<span class="count-info">7次</span>
</div>
<div class="news-title">
<a href="https://www.baidu.com/s?wd=%E3%80%8A%E5%93%AA%E5%90%922%E3%80%8B%E7%89%87%E6%96%B9%E6%88%96%E5%88%86%E8%B4%A652%E4%BA%BF%E5%85%83" target="_blank" class="news-link">《哪吒2》片方或分账52亿元</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">1 条</div>
</div>
<div class="word-index">4/4</div>
</div>
<div class="news-item">
<div class="news-number">1</div>
<div class="news-content">
<div class="news-header">
<span class="source-name">zhihu</span>
<span class="rank-num top">5</span>
<span class="time-info">06:55~07:17</span>
<span class="count-info">2次</span>
</div>
<div class="news-title">
<a href="https://www.zhihu.com/question/1905395386765537540" target="_blank" class="news-link">目前原神所有自机角色谁最有可能出新形态?</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>
</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 wordGroups = Array.from(container.querySelectorAll('.word-group'));
const header = container.querySelector('.header');
const footer = container.querySelector('.footer');
const containerRect = container.getBoundingClientRect();
const elements = [];
elements.push({
type: 'header',
element: header,
top: 0,
bottom: header.offsetHeight,
height: header.offsetHeight
});
wordGroups.forEach(group => {
const groupRect = group.getBoundingClientRect();
const wordHeader = group.querySelector('.word-header');
if (wordHeader) {
const headerRect = wordHeader.getBoundingClientRect();
elements.push({
type: 'word-header',
top: groupRect.top - containerRect.top,
bottom: headerRect.bottom - containerRect.top,
height: headerRect.height
});
}
group.querySelectorAll('.news-item').forEach(item => {
const rect = item.getBoundingClientRect();
elements.push({
type: 'news-item',
top: rect.top - containerRect.top,
bottom: rect.bottom - containerRect.top,
height: rect.height
});
});
});
const footerRect = footer.getBoundingClientRect();
elements.push({
type: 'footer',
top: footerRect.top - containerRect.top,
bottom: footerRect.bottom - containerRect.top,
height: footer.offsetHeight
});
const segments = [];
let currentSegment = { start: 0, end: 0, height: 0 };
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
};
} 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;
`;
const clonedContainer = container.cloneNode(true);
const clonedButtons = clonedContainer.querySelector('.save-buttons');
if (clonedButtons) {
clonedButtons.style.display = 'none';
}
tempContainer.appendChild(clonedContainer);
document.body.appendChild(tempContainer);
await new Promise(resolve => setTimeout(resolve, 100));
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>