惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Docker
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 聂微东
MyScale Blog
MyScale Blog
H
Help Net Security
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
M
MIT News - Artificial intelligence
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Proofpoint News Feed
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏

朽丘秋雨

关于备案、主题开发和短暂停更的一点说明 | 柯讴朽丘的生活日志 如何启用域名DNSSEC的设置以及吃瓜某蒂云服务商跑路这件事 快速登记自己的作品版权合法保护自己的绘画等艺术作品 实现Artalk中间页安全跳转和表情包小图BUG预览 小柯庆生这件事 一则域名通知申明 春节游记 简易的链接反馈 舟终末地初玩体验 给Hexo和留言添加跳转中间页 再见2025,你好2026 小站最新装修 25年11月灌水闲说 放下热爱,归向烟火,致大家的一封告别与交代信 比起顺意哄劝,我选笨拙地托你往亮处走 25年7月小结 代际观念与亲情现实的双重困局 25年6月小结 封建派还是自由派,真的是我封建吗 心悦君兮君不知,一寸相思一寸灰 25年4月小结 四月自我笔记 25年3月小结 25年2月小结 25年1月小结 漂泊异乡终归巢 社会变迁与个人成长:一种代际观察 好耶,热乎着,新形象! 再见2024,你好2025 24年12月小结
最近的改动和生活
klcdm · 2026-03-26 · via 朽丘秋雨
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
/* 引入Markdown解析库 - 新增代码开始 */
!function(){
// 动态加载marked库(选用的大厂的CDN)
if (!window.marked) {
const script = document.createElement('script');
script.src = 'https://cdn.jsdmirror.com/npm/marked@12.0.2/marked.min.js';
script.async = true;
document.head.appendChild(script);

// 可选:添加代码高亮支持(如果需要解析代码块)
const highlightScript = document.createElement('script');
highlightScript.src = 'https://cdn.jsdmirror.com/npm/highlight.js@11.9.0/lib/highlight.min.js';
highlightScript.async = true;
document.head.appendChild(highlightScript);

const highlightCss = document.createElement('link');
highlightCss.rel = 'stylesheet';
highlightCss.href = 'https://cdn.jsdmirror.com/npm/highlight.js@11.9.0/styles/github.min.css';
document.head.appendChild(highlightCss);
}
}();
/* 引入Markdown解析库 - 新增代码结束 */

/* LiuShen Echo System - XSCNET Adapted Version */
/* 原作者Liushen : https://blog.liushen.fun/posts/e0b4d5a/ */
// 定义一个自执行的匿名函数,创建独立作用域
!function () {
// 初始化全局状态对象,用于管理定时器和事件监听器
const n = window.__mete0rShuoshuoState || (window.__mete0rShuoshuoState = {
resizeHandler: null, // 窗口大小改变事件处理器
afterRenderTimer: null, // 渲染后延迟执行的定时器
listenersBound: !1 // 是否已绑定事件监听器标记
});

// --- 核心配置区 ---
const xscConfig = {
apiUrl: '【】', // API地址,获取说说数据的接口
avatar: '【】', // 默认头像URL
nickname: '【】' // 默认昵称
};

// 清理函数:清除定时器和移除窗口大小改变事件监听器
function a() {
n.afterRenderTimer && (window.clearTimeout(n.afterRenderTimer), n.afterRenderTimer = null),
n.resizeHandler && (window.removeEventListener("resize", n.resizeHandler), n.resizeHandler = null)
}

// 主要功能函数:初始化和渲染说说列表
function r() {
a(); // 清理之前的定时器和事件监听器
const r = document.querySelector("#talk"); // 获取说说容器元素
if (!r) return; // 如果找不到容器则直接返回
r.innerHTML = ""; // 清空容器内容

// 瀑布流布局函数:实现图片/卡片的瀑布流排列
const o = e => {
// 获取元素指定方向的外边距值
function t(e, t) {
const n = window.getComputedStyle(t);
return parseFloat(n[`margin${e}`]) || 0
}

// 将数值转换为带像素单位的字符串
function r(e) { return `${e}px` }

// 获取元素的左边距位置
function i(e) { return parseFloat(e.style.left) }

// 获取元素的宽度
function l(e) { return e.clientWidth }

// 计算元素底部位置(顶部位置+高度+下边距)
function s(e) {
return function (e) { return parseFloat(e.style.top) }(e) +
function (e) { return e.clientHeight }(e) +
t("Bottom", e)
}

// 计算元素右边位置(左边位置+宽度+右边距)
function c(e) { return i(e) + l(e) + t("Right", e) }

// 对元素数组按从下到上的顺序进行排序
function d(e) {
e.sort(((e, t) => s(e) === s(t) ? i(t) - i(e) : s(t) - s(e)))
}

// 如果传入的是字符串选择器,则获取对应DOM元素
if ("string" == typeof e && (e = document.querySelector(e)), !e) return;

// 设置子元素绝对定位,并收集到数组中
const u = Array.from(e.children).map((e => (e.style.position = "absolute", e)));
e.style.position = "relative"; // 设置父容器相对定位

const p = []; // 存储当前每列底部位置的元素

// 处理第一行元素:设置第一个元素的位置
u.length && (u[0].style.top = "0px", u[0].style.left = r(t("Left", u[0])), p.push(u[0]));
let m = 1; // 从第二个元素开始循环

// 将能放在第一行的元素水平排列
for (; m < u.length; m += 1) {
const n = u[m - 1], a = u[m]; // 当前元素和前一个元素
if (!(c(n) + l(a) <= l(e))) break; // 如果超出容器宽度则跳出循环
a.style.top = n.style.top, a.style.left = r(c(n) + t("Left", a)), p.push(a) // 设置元素位置
}

// 处理剩余元素:依次放置到最短列的下方
for (; m < u.length; m += 1) {
d(p); // 排序找到最短列
const e = u[m], n = p.pop(); // 取出当前最短列的底部元素
e.style.top = r(s(n) + t("Top", e)), e.style.left = r(i(n)), p.push(e) // 放置元素
}

d(p); // 最终排序
const h = p[0]; // 找到最高列的底部元素
e.style.height = h ? r(s(h) + t("Bottom", h)) : "0px"; // 设置容器高度

const f = l(e); // 记录初始容器宽度
// 设置窗口大小改变时的处理函数
n.resizeHandler = () => {
const e = document.querySelector("#talk");
e && document.body.contains(e) ? l(e) !== f && o(e) : a() // 如果容器存在且尺寸改变,则重新计算布局
},
window.addEventListener("resize", n.resizeHandler) // 添加窗口大小改变事件监听器
},

// 提取扩展信息函数:从数据对象中提取extension字段
i = e => {
const t = e?.extension;
return t && "object" == typeof t ? t : null
},

// 获取标签数组函数:从数据对象中提取标签,如果没有则默认返回"碎碎念"
l = e => Array.isArray(e?.tags) && e.tags.length ?
e.tags.map((e => e?.name || e)).filter(Boolean) :
["💬 碎碎念"],

// 格式化日期函数:将日期字符串格式化为年月日时分格式
s = e => {
const t = new Date(e); // 创建日期对象
if (isNaN(t.getTime())) return "刚刚"; // 如果日期无效则返回"刚刚"
const n = e => String(e).padStart(2, "0"); // 补零函数
// 返回格式化的日期时间字符串
return `${t.getFullYear()}-${n(t.getMonth() + 1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`
},

// 生成外部链接HTML函数:根据类型生成网站或GitHub项目链接
c = (e, t) => {
if (!t) return ""; // 如果没有数据则返回空字符串
let n = "", a = "", r = "【404图】";

// 处理网站链接
if ("WEBSITE" === e) {
n = t.site || t.url || "", a = t.title || n
}

// 处理GitHub项目链接
if ("GITHUBPROJ" === e) {
n = t.repoUrl || t.url || "",
a = t.title || (e => {
if (!e) return "";
// 提取GitHub仓库名称
const t = e.match(/^https?:\/\/github\.com\/[^/]+\/([^/?#]+)/i);
if (t) return t[1];
return e
})(n);
r = "【】" // GitHub图标
}

// 返回格式化的外部链接HTML结构
return n ? `\n<div class="shuoshuo-external-link"><a class="external-link" href="${n}" target="_blank" rel="nofollow noopener"><div class="external-link-left" style="background-image:url(${r})"></div><div class="external-link-right"><div class="external-link-title">${a}</div><div>点击跳转<i class="fa-solid fa-angle-right"></i></div></div></a></div>` : ""
},

// 生成B站视频嵌入函数:根据BVID生成B站视频iframe
d = e => {
const t = e?.videoId || e?.url || ""; if (!t) return ""; // 获取视频ID或URL
let n = "";
if (/^BV[0-9A-Za-z]+$/i.test(t)) // 验证是否为有效的BVID
n = `https://www.bilibili.com/blackboard/html5mobileplayer.html?bvid=${t}&as_wide=1&high_quality=1&danmaku=0`;
// 返回视频iframe HTML
return n ? `<div style="position: relative; padding: 30% 45%; margin-top: 10px;"><iframe style="position:absolute;width:100%;height:100%;left:0;top:0;border-radius:12px;" src="${n}" frameborder="0" allowfullscreen loading="lazy"></iframe></div>` : ""
},

// 生成轮播图HTML函数:将图片数组转换为轮播图结构(已升级支持LivePhoto)
carouselHtml = (images, liveVideos = []) => {
if (!images || images.length === 0) return '';

// 内部函数:生成单个幻灯片的HTML,包含Live视频和图标
const generateSlideHtml = (img, index, isActive) => {
const videoUrl = liveVideos[index];
const hasLive = !!videoUrl;
return `<div class="carousel-slide${isActive ? ' active' : ''}${hasLive ? ' has-live' : ''}">
<a href="${img}" class="carousel-image-link no-direct-link" data-fancybox="gallery" data-src="${img}">
<img src="${img}" loading="lazy" alt="图片">
${hasLive ? `
<div class="live-badge">
<svg class="live-icon" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-352a96 96 0 1 1 0 192 96 96 0 1 1 0-192z" fill="currentColor"/></svg>
<span>LIVE</span>
</div>
<video class="live-video" src="${videoUrl}" loop muted playsinline preload="metadata"></video>
` : ''}
</a>
</div>`;
};

if (images.length === 1) {
// 只有一张图片时
return `<div class="image-carousel">
<div class="carousel-container single-image">
${generateSlideHtml(images[0], 0, true)}
</div>
</div>`;
} else {
// 多张图片时,显示轮播图
let slides = images.map((img, index) => generateSlideHtml(img, index, index === 0)).join('');

return `<div class="image-carousel">
<div class="carousel-container multi-images">
${slides}
<button class="carousel-btn prev-btn" type="button" aria-label="上一张">&#10094;</button>
<button class="carousel-btn next-btn" type="button" aria-label="下一张">&#10095;</button>
<div class="carousel-indicators">
${images.map((_, index) => `<span class="indicator${index === 0 ? ' active' : ''}" data-index="${index}"></span>`).join('')}
</div>
</div>
</div>`;
}
},

// 阻止链接默认行为直到插件加载完成
preventImageLinkDefault = () => {
// 添加事件委托,阻止图片链接的默认行为直到 fancybox 加载完成
document.addEventListener('click', function (e) {
// 检查是否点击的是图片链接且属于我们的图片链接类
const imageLink = e.target.closest('.carousel-image-link.no-direct-link');
if (imageLink) {
e.preventDefault();
e.stopPropagation();

// 检查是否已加载 fancybox
if (typeof Fancybox !== 'undefined' && typeof Fancybox.bind !== 'undefined') {
// 如果已加载,直接打开 fancybox
const galleryImages = [];
const container = imageLink.closest('.carousel-container');

// 如果是轮播图,收集所有图片;如果是单张图片,就只有一张
if (container) {
const links = container.querySelectorAll('.carousel-image-link');
links.forEach((link, index) => {
galleryImages.push({
src: link.getAttribute('href'),
thumb: link.querySelector('img').src
});

// 如果点击的就是当前这张图片,记录索引
if (link === imageLink) {
Fancybox.show(galleryImages, { startIndex: index });
}
});
} else {
// 单个图片的情况
Fancybox.show([{
src: imageLink.getAttribute('href'),
thumb: imageLink.querySelector('img').src
}]);
}
} else {
// 如果未加载,显示提示信息或等待
console.log("正在加载图片查看器...");

// 尝试多次检查 fancybox 是否加载完成
const checkFancyboxAndShow = () => {
if (typeof Fancybox !== 'undefined' && typeof Fancybox.bind !== 'undefined') {
const galleryImages = [];
const container = imageLink.closest('.carousel-container');

if (container) {
const links = container.querySelectorAll('.carousel-image-link');
links.forEach((link, index) => {
galleryImages.push({
src: link.getAttribute('href'),
thumb: link.querySelector('img').src
});

// 如果点击的就是当前这张图片,记录索引
if (link === imageLink) {
Fancybox.show(galleryImages, { startIndex: index });
}
});
} else {
// 单个图片的情况
Fancybox.show([{
src: imageLink.getAttribute('href'),
thumb: imageLink.querySelector('img').src
}]);
}
} else {
setTimeout(checkFancyboxAndShow, 100); // 100ms 后再检查
}
};

checkFancyboxAndShow();
}
}
}, true); // 使用捕获阶段确保在其他事件处理程序之前执行
},

/* Markdown渲染函数 - 新增代码开始 */
// 解析Markdown为HTML
renderMarkdown = (text) => {
if (!text || typeof text !== 'string') return '';
// 等待marked加载完成
if (!window.marked) {
// 如果marked未加载,先返回原始文本,延迟后重新渲染
setTimeout(() => {
document.querySelectorAll('.talk_content_text').forEach(el => {
el.innerHTML = renderMarkdown(el.textContent);
});
m(); // 重新计算布局
}, 500);
return text.replace(/\n/g, '<br>');
}

// 配置marked
marked.setOptions({
breaks: true, // 换行符转换为<br>
gfm: true, // 启用GitHub风格的Markdown
highlight: function(code, lang) {
// 如果有highlight.js且指定了语言,进行代码高亮
if (window.hljs && lang) {
try {
return hljs.highlight(code, { language: lang }).value;
} catch (err) {
return hljs.highlightAuto(code).value;
}
}
return code;
}
});

// 解析Markdown
return marked.parse(text);
},
/* Markdown渲染函数 - 新增代码结束 */

// 格式化单条说说内容函数:处理文本、图片、视频、外部链接等
u = e => {
// 解析扩展信息
const t = (e => i(e)?.type || "")(e),
n = (e => i(e)?.payload || null)(e),
a = e?.content || ""; // 获取说说内容

// --- LivePhoto 视频提取逻辑 ---
const liveRegex = /\[live\](https?:\/\/[^\s<]+)/g;
let liveVideos = [];
let match;
while ((match = liveRegex.exec(a)) !== null) {
liveVideos.push(match[1]); // 提取带前缀的视频URL
}
// 从正文中剔除 [live] 链接,确保文字不显示干扰
const cleanText = a.replace(liveRegex, '').trim();

// --- 强制视频链接解析逻辑 ---
let videoHtml = "";
// YouTube和B站视频链接正则表达式
const youtubeRegex = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
const bilibiliRegex = /(?:https?:\/\/)?(?:www\.)?bilibili\.com\/video\/(BV[0-9A-Za-z]+)/;

const ytMatch = cleanText.match(youtubeRegex); // 在清洗后的文本中匹配YouTube链接
const bMatch = cleanText.match(bilibiliRegex); // 在清洗后的文本中匹配B站链接

// 如果匹配到YouTube或B站链接,则生成对应的iframe
if (ytMatch) {
videoHtml = `<div class="video-wrapper"><iframe src="https://www.youtube.com/embed/${ytMatch[1]}" frameborder="0" allowfullscreen></iframe></div>`;
} else if (bMatch) {
videoHtml = `<div class="video-wrapper"><iframe src="https://www.bilibili.com/blackboard/html5mobileplayer.html?bvid=${bMatch[1]}&as_wide=1&high_quality=1&danmaku=0" frameborder="0" allowfullscreen></iframe></div>`;
}

// 处理文本内容:替换复选框标记并使用Markdown渲染 - 修改这一行
let o = `<div class="talk_content_text">${(e => renderMarkdown((e || "").replace(/- \[ \]/g, "[]").replace(/- \[x\]/gi, "[x]")))(cleanText)}</div>`;

// 渲染视频
o += videoHtml;

// 渲染图片 - 现在使用轮播图功能
const r = (e => Array.isArray(e?.echo_files) ?
e.echo_files.map((e => e?.file || e))
.filter(e => String(e?.category || "").toLowerCase() === "image")
.map(e => e?.url).filter(Boolean) : [])(e);

// 生成轮播图HTML (传入提取的liveVideos数组)
if (r.length > 0) {
o += carouselHtml(r, liveVideos);
}

// 检查扩展类型并添加外部链接或音乐
if (t === "WEBSITE" || t === "GITHUBPROJ") o += c(t, n);
if (t === "MUSIC") o += ((e) => {
// 解析音乐链接,识别网易云或QQ音乐
const t = ((e) => {
const t = e?.url;
if (!t) return null;
// 根据URL判断音乐平台
let n = t.includes("music.163.com") ? "netease" : t.includes("y.qq.com") ? "tencent" : "";
const a = t.match(/id=(\d+)/); // 提取音乐ID
return n && a ? { server: n, id: a[1] } : null
})(e);
// 返回MetingJS音乐播放器HTML
return t ? `<meting-js server="${t.server}" type="song" id="${t.id}" mini="false"></meting-js>` : ""
})(n);
if (t === "VIDEO") o += d(n);

// 返回格式化后的说说对象
return {
content: o,
user: xscConfig.nickname, // 用户名
avatar: xscConfig.avatar, // 头像
date: s(e?.created_at), // 格式化后的日期
tags: l(e), // 标签数组
quoteText: cleanText // 原始文本内容(引用回复使用清洗后的文字)
}
};

// 引用回复函数:在评论框中填入引用文本并滚动到评论区
p = e => {
// 查找评论框元素(支持Element UI和Artalk)
const t = document.querySelector(".el-textarea__inner") || document.querySelector(".atk-textarea");
if (t) {
t.value = `> ${e || ""}\n\n`; // 在评论框中填入引用格式
t.focus(); // 聚焦到评论框
t.dispatchEvent(new Event('input', { bubbles: true })); // 触发输入事件
// 查找评论区并平滑滚动到该区域
const tw = document.querySelector('#twikoo') || document.querySelector('#artalk');
tw && tw.scrollIntoView({ behavior: 'smooth' })
}
},

// 布局更新函数:重新计算瀑布流布局并更新懒加载和灯箱效果
m = () => {
o("#talk"), // 重新计算瀑布流布局
window.btf?.loadLightbox && btf.loadLightbox(document.querySelectorAll("#talk img:not(.no-lightbox)")), // 加载灯箱效果
window.lazyLoadInstance?.update && lazyLoadInstance.update(); // 更新懒加载实例

// 初始化轮播图功能
initCarousel();
},

// 初始化轮播图功能
initCarousel = () => {
const carousels = document.querySelectorAll('.image-carousel');

carousels.forEach(carousel => {
const container = carousel.querySelector('.carousel-container');

// --- LivePhoto 交互逻辑开始 ---
const slidesWithLive = carousel.querySelectorAll('.carousel-slide.has-live');
slidesWithLive.forEach(slide => {
const video = slide.querySelector('.live-video');
const img = slide.querySelector('img');

// 添加一个标志来跟踪视频是否已完成播放
let hasVideoPlayed = false;

// 鼠标进入:播放视频,隐藏图片
slide.addEventListener('mouseenter', () => {
// 如果视频尚未播放过,或者已经播放完成但鼠标离开了再回来,则重新播放
if (!hasVideoPlayed) {
video.currentTime = 0; // 确保每次从头播放
video.play().catch(e => console.warn("LivePhoto播放被阻挡"));
video.style.opacity = "1";
img.style.opacity = "0";
hasVideoPlayed = true;
}
});

// 鼠标离开:停止视频,恢复图片显示,并重置播放状态
slide.addEventListener('mouseleave', () => {
video.pause();
video.currentTime = 0; // 重置进度
video.style.opacity = "0";
img.style.opacity = "1";
hasVideoPlayed = false; // 重置播放状态
});

// 视频播放结束:恢复图片显示,但不重置播放状态
video.addEventListener('ended', () => {
video.style.opacity = "0";
img.style.opacity = "1";
// 不重置hasVideoPlayed,保持为true表示视频已经播放完成
});
});
// --- LivePhoto 交互逻辑结束 ---

if (container.classList.contains('single-image')) return; // 单张图片无需翻页处理

const slides = carousel.querySelectorAll('.carousel-slide');
const prevBtn = carousel.querySelector('.prev-btn');
const nextBtn = carousel.querySelector('.next-btn');
const indicators = carousel.querySelectorAll('.indicator');
let currentIndex = 0;

// 显示当前幻灯片
const showSlide = (index) => {
slides.forEach((slide, i) => {
slide.classList.toggle('active', i === index);
});

indicators.forEach((indicator, i) => {
indicator.classList.toggle('active', i === index);
});

currentIndex = index;
};

// 下一张
const nextSlide = () => {
const nextIndex = (currentIndex + 1) % slides.length;
showSlide(nextIndex);
};

// 上一张
const prevSlide = () => {
const prevIndex = (currentIndex - 1 + slides.length) % slides.length;
showSlide(prevIndex);
};

// 绑定按钮事件
if (prevBtn) prevBtn.addEventListener('click', (e) => { e.preventDefault(); e.stopPropagation(); prevSlide(); });
if (nextBtn) nextBtn.addEventListener('click', (e) => { e.preventDefault(); e.stopPropagation(); nextSlide(); });

// 绑定指示器事件
indicators.forEach((indicator, index) => {
indicator.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
showSlide(index);
});
});

// 键盘支持
container.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft') prevSlide();
if (e.key === 'ArrowRight') nextSlide();
});
});
},

// 渲染说说列表函数:将数据转换为DOM元素并添加到页面
h = e => {
// 将数据映射为DOM元素并添加到容器中
e.map(u).forEach((e => r.appendChild((e => {
// 创建说说项容器
const t = document.createElement("div"); t.className = "talk_item card-shadow";

// 创建元信息区域(头像和用户名)
const n = document.createElement("div"); n.className = "talk_meta";

// 创建头像图片元素
const a = document.createElement("img"); a.className = "no-lightbox avatar"; a.src = e.avatar;

// 创建用户信息容器
const r = document.createElement("div"); r.className = "info";

// 创建用户名标签,包含认证标识
const o = document.createElement("span"); o.className = "talk_nick";
o.innerHTML = `${e.user} <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" class="is-badge icon" style="width:14px;margin-left:4px;vertical-align:middle;"><path d="m512 268c0 17.9-4.3 34.5-12.9 49.7s-20.1 27.1-34.6 35.4c.4 2.7.6 6.9.6 12.6 0 27.1-9.1 50.1-27.1 69.1-18.1 19.1-39.9 28.6-65.4 28.6-11.4 0-22.3-2.1-32.6-6.3-8 16.4-19.5 29.6-34.6 39.7-15 10.2-31.5 15.2-49.4 15.2-18.3 0-34.9-4.9-49.7-14.9-14.9-9.9-26.3-23.2-34.3-40-10.3 4.2-21.1 6.3-32.6 6.3-25.5 0-47.4-9.5-65.7-28.6-18.3-19-27.4-42.1-27.4-69.1 0-3 .4-7.2 1.1-12.6-14.5-8.4-26-20.2-34.6-35.4-8.5-15.2-12.8-31.8-12.8-49.7 0-19 4.8-36.5 14.3-52.3s22.3-27.5 38.3-35.1c-4.2-11.4-6.3-22.9-6.3-34.3 0-27 9.1-50.1 27.4-69.1s40.2-28.6 65.7-28.6c11.4 0 22.3 2.1 32.6 6.3 8-16.4 19.5-29.6 34.6-39.7 15-10.1 31.5-15.2 49.4-15.2s34.4 5.1 49.4 15.1c15 10.1 26.6 23.3 34.6 39.7 10.3-4.2 21.1-6.3 32.6-6.3 25.5 0 47.3 9.5 65.4 28.6s27.1 42.1 27.1 69.1c0 12.6-1.9 24-5.7 34.3 16 7.6 28.8 19.3 38.3 35.1 9.5 15.9 14.3 33.4 14.3 52.4zm-266.9 77.1 105.7-158.3c2.7-4.2 3.5-8.8 2.6-13.7-1-4.9-3.5-8.8-7.7-11.4-4.2-2.7-8.8-3.6-13.7-2.9-5 .8-9 3.2-12 7.4l-93.1 140-42.9-42.8c-3.8-3.8-8.2-5.6-13.1-5.4-5 .2-9.3 2-13.1 5.4-3.4 3.4-5.1 7.7-5.1 12.9 0 5.1 1.7 9.4 5.1 12.9l58.9 58.9 2.9 2.3c3.4 2.3 6.9 3.4 10.3 3.4 6.7-.1 11.8-2.9 15.2-8.7z" fill="#1da1f2"></path></svg>`;

// 创建日期标签
const i = document.createElement("span"); i.className = "talk_date"; i.textContent = e.date;

// 组装元信息区域
r.appendChild(o); r.appendChild(i); n.appendChild(a); n.appendChild(r);

// 创建内容区域
const l = document.createElement("div"); l.className = "talk_content"; l.innerHTML = e.content;

// 创建底部区域
const s = document.createElement("div"); s.className = "talk_bottom";

// 创建标签容器
const c = document.createElement("div"), d = document.createElement("span");
d.className = "talk_tag"; d.textContent = `🏷️ ${e.tags.join(" / ")}`;
c.appendChild(d);

// 创建评论按钮
const u = document.createElement("a");
u.className = "comment_btn";
u.href = "javascript:;";
u.addEventListener("click", (() => p(e.quoteText))); // 点击时触发引用回复
u.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="width:16px;fill:currentColor;"><path d="M256 32C114.6 32 0 125.1 0 240c0 47.6 19.9 91.2 52.9 126.3C38 405.7 7 439.1 6.5 439.5c-6.6 7-8.4 17.2-4.6 26S14.4 480 24 480c61.5 0 110-25.7 139.1-46.3C192 442.8 223.2 448 256 448c141.4 0 256-93.1 256-208S397.4 32 256 32zm0 368c-26.7 0-53.1-4.1-78.4-12.1l-22.7-7.2-19.5 13.8c-14.3 10.1-33.9 21.4-57.5 29 7.3-12.1 14.4-25.7 19.9-40.2l10.6-28.1-20.6-21.8C69.7 314.1 48 282.2 48 240c0-88.2 93.3-160 208-160s208 71.8 208 160-93.3 160-208 160z"></path></svg>';

// 组装底部区域
return s.appendChild(c), s.appendChild(u), t.appendChild(n), t.appendChild(l), t.appendChild(s), t
})(e)))),
m(); // 执行布局更新

// 为视频和图片添加加载事件监听器
setTimeout(() => {
m(); // 初次渲染后再次调用瀑布流布局

// 为所有媒体元素添加加载完成事件监听
r.querySelectorAll("img, iframe, meting-js").forEach((e => {
e.addEventListener("load", m, { once: !0 });

if (e.complete && (e.tagName === 'IMG' || e.tagName === 'IFRAME')) {
m();
}
}));

// 监听 MetingJS 初始化完成事件
const initMetingObserver = () => {
const metingElements = r.querySelectorAll('meting-js');
if (metingElements.length > 0) {
const observer = new MutationObserver((mutationsList) => {
let shouldRefresh = false;
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach(node => {
if (node.nodeType === 1 && (node.classList.contains('aplayer') || node.querySelector('.aplayer'))) {
shouldRefresh = true;
}
});
if (shouldRefresh) {
setTimeout(() => { m(); }, 100);
break;
}
}
}
});
metingElements.forEach(metingEl => {
observer.observe(metingEl, { childList: true, subtree: true });
});
setTimeout(() => { observer.disconnect(); }, 5000);
}
};

setTimeout(initMetingObserver, 100);

}, 100);

n.afterRenderTimer = window.setTimeout(m, 300)
};

// 防止图片链接默认行为
preventImageLinkDefault();

// 获取数据并渲染的立即执行函数
(() => {
fetch(xscConfig.apiUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ page: 1, pageSize: 50 })
})
.then(e => e.json()).then(n => {
if (1 !== n?.code) return;
h(n.data.items)
})
})()
}

window.initShuoshuoPage = r,
n.listenersBound || (document.addEventListener("pjax:complete", r), n.listenersBound = !0),
r()
}();