feat(matrix): 逐条标题可点击,直接打开抖音作品
Deploy VitePress site to Pages / build (push) Canceled after 0s
Deploy VitePress site to Pages / Deploy (push) Canceled after 0s

details 里带上入库时拼好的 note_url。提示框改成可交互(原来 pointer-events:
none 是为了防闪烁),离开格子后延迟 250ms 再收、鼠标进入提示就取消,点标题
不会因为提示消失而落空。没有地址的老数据仍按纯文字显示。
This commit is contained in:
2026-10-25 09:06:44 +08:00
parent e369478ff1
commit 3a5b973bc2
3 changed files with 46 additions and 9 deletions
+38 -6
View File
@@ -207,13 +207,13 @@
}
#login a { color: var(--cyan); }
/* 悬停提示。跟着格子走,但不吃鼠标事件 —— 否则它一出现就会盖住格子、
触发 mouseleave,然后自己消失,来回闪。 */
/* 悬停提示。跟着格子走。**可交互**:里面的标题是链接,要能点。
防闪烁靠「离开格子后延迟 250ms 再收」+ 进入提示就取消(见 scheduleHide)。 */
#tip {
display: none;
position: fixed;
z-index: 100;
pointer-events: none;
pointer-events: auto;
max-width: 320px;
padding: 8px 10px;
border: 1px solid var(--line);
@@ -238,6 +238,13 @@
}
#tip .tip-note { margin-bottom: 4px; line-height: 1.55; }
#tip .tip-note-title { color: var(--text); }
/* 标题就是作品链接,点一下在抖音打开。 */
#tip a.tip-note-title {
color: var(--cyan);
text-decoration: none;
cursor: pointer;
}
#tip a.tip-note-title:hover { text-decoration: underline; }
/* 每条作品自己的指标。缩进到标题文字下面,一眼对得上是哪条。 */
#tip .tip-note-meta {
padding-left: 14px;
@@ -296,6 +303,7 @@
<span><b>名字左边</b> = 粉丝数</span>
<span><b>赞 / 评</b> = 当天这些作品的点赞 / 评论</span>
<span><b>左下角数字</b> = 当天作品条数</span>
<span><b>悬停后点标题</b> = 在抖音打开这条作品</span>
<span><b>无标签</b> = 发了但没打标签</span>
<span><b>空白</b> = 当天没发作品</span>
<span>鼠标停到格子上可以看当天的点赞 / 评论 / 收藏 / 分享</span>
@@ -314,6 +322,8 @@
const cfValueInput = document.getElementById('cfValue');
// 条件格式只在本地重渲染,不重新请求 —— 指标已经随格子一起返回了。
let lastData = null;
// 离开格子之后延迟收起提示的计时器:提示里的标题是链接,鼠标要从格子挪进去点。
let hideTimer = null;
function setStatus(text, isError) {
statusEl.textContent = text;
@@ -350,9 +360,16 @@
}
function hideTip() {
clearTimeout(hideTimer);
tip.style.display = 'none';
}
/** 离开格子时不立刻收 —— 留一点时间让鼠标移进提示里点标题。 */
function scheduleHide() {
clearTimeout(hideTimer);
hideTimer = setTimeout(hideTip, 250);
}
function cfThreshold() {
const raw = cfValueInput.value.trim();
if (raw === '') return null;
@@ -424,9 +441,20 @@
const row = document.createElement('div');
row.className = 'tip-note';
const title = document.createElement('div');
// 标题就是链接:点一下跳去抖音看原视频。没有地址的老数据就还是纯文字。
const titleText = index + 1 + '. ' + item.title;
let title;
if (item.url) {
title = document.createElement('a');
title.href = item.url;
title.target = '_blank';
title.rel = 'noopener noreferrer';
title.title = '在抖音打开';
} else {
title = document.createElement('div');
}
title.className = 'tip-note-title';
title.textContent = index + 1 + '. ' + item.title;
title.textContent = titleText;
row.appendChild(title);
const meta = document.createElement('div');
@@ -462,6 +490,7 @@
const td = event.currentTarget;
const cell = td._cell;
if (!cell) return;
clearTimeout(hideTimer);
buildTip(cell, td.dataset.day, td.dataset.creator);
tip.style.display = 'block';
@@ -521,7 +550,7 @@
td.dataset.creator = creatorName;
if (cfHit(cell)) td.classList.add('hit');
td.addEventListener('mouseenter', showTip);
td.addEventListener('mouseleave', hideTip);
td.addEventListener('mouseleave', scheduleHide);
return td;
}
@@ -677,6 +706,9 @@
cfValueInput.addEventListener('input', rerender);
// 表格滚动时把提示收起来,否则它会停在原地、和格子脱节。
wrap.addEventListener('scroll', hideTip);
// 鼠标移进提示里(点标题)就取消收起;移出去再收。
tip.addEventListener('mouseenter', () => clearTimeout(hideTimer));
tip.addEventListener('mouseleave', hideTip);
init();
</script>
</body>