fix: 修复首页卡片字数与 Hero 滚动,移除光感跟随 (v1.1.6)

修复
- 首页文章卡片开启"显示字数"后无效果:该配置项此前只有声明没有实现,现已在文章流卡片接入服务端字数统计(依赖 API 扩展包,未安装时自动隐藏)
- Hero 下滑箭头滚动不到位:Hero 为固定背景(position: fixed),此前箭头额外减去了导航栏高度,导致内容区上方始终露出一段 Hero 渐变;现与滚动吸附逻辑对齐,内容区顶部直接对齐视口顶部
- 鼠标点击特效开启后无效果:特效类型默认值为 off(关闭),开启开关但不选择类型时静默不生效;默认值改为"社会主义核心价值观"

移除
- 移除鼠标光感跟随功能及对应配置项

优化
- 上下篇导航:新增方向箭头与悬停反馈(背景、位移、变色),移动端收紧内边距
- Hero 一言自动刷新改为淡出→换文案→淡入的过渡动画,避免生硬跳变
- README 全面更新:环境要求、插件适配表(新增微信读书与 API 扩展包)、自定义页面模板、功能说明、目录结构与开发注意事项
This commit is contained in:
2026-09-26 12:29:28 +08:00
parent 430d107d44
commit bcc221c3bd
10 changed files with 180 additions and 105 deletions
+15 -8
View File
@@ -100,6 +100,7 @@
var top;
if (content) {
/* 与首页滚动吸附逻辑保持一致:内容区顶部对齐视口顶部,完全盖住固定背景的 Hero */
top = content.getBoundingClientRect().top + window.pageYOffset;
} else if (hero) {
top = hero.offsetTop + hero.offsetHeight;
@@ -107,16 +108,12 @@
top = window.innerHeight;
}
/* 预留固定导航栏的高度,避免内容被顶栏遮住 */
var navbar = document.getElementById("wi-navbar");
var offset = navbar ? navbar.offsetHeight + 8 : 8;
var reduce =
window.matchMedia &&
window.matchMedia("(prefers-reduced-motion: reduce)").matches;
window.scrollTo({
top: Math.max(0, top - offset),
top: Math.max(0, top),
behavior: reduce ? "auto" : "smooth",
});
});
@@ -158,17 +155,27 @@
return res.json();
})
.then(function (data) {
el.style.opacity = "1";
var text = data.hitokoto || "";
var from = data.from || data.from_who || "";
if (from) {
text += " \u2014\u2014 " + from;
}
el.textContent = text;
if (initial) {
el.style.opacity = "1";
el.textContent = text;
} else {
/* 自动刷新:淡出 → 换文案 → 淡入,避免生硬跳变 */
el.style.opacity = "0";
setTimeout(function () {
el.textContent = text;
el.style.opacity = "1";
}, 280);
}
})
.catch(function () {
// 失败时恢复可见:首次为空,刷新时保留原文案
el.style.opacity = "1";
// 自动刷新失败时保留原文案,避免闪烁成空白
if (initial) el.textContent = "";
});
}