- 图库页重做:首屏按相册分组展示,封面自动取相册第一张图,可在设置中按相册手动配置封面;点击相册进入 ?group= 瀑布流视图(一行三张、页面加宽),支持预览模式(lightgallery 放大,默认值可配置、前台可切换)
- 瞬间页:新增 /moments/{name} 详情页(完整内容、媒体、标签、作者信息、评论区);列表页发布人与发布时间同行对齐;补充单条标签
- 新增 plugin-important-dates 适配页 important-dates.html(即将到来提醒、全部日期倒计时、重要标记、人员生日)
- 全站集成 lightgallery.js 灯箱(动态模式、按需加载、挂载 body 避免层叠上下文遮挡),可在设置中关闭
- 友链页:「全部」视图按分组展示并显示分组标题(空分组自动隐藏);卡片简介限制两行,统一卡片高度与尺寸
- 修复 /douban 白屏:SpEL 不支持 th:with 中的嵌套 map 字面量(EL1041E),改为四段显式区块
- 版本号升至 0.2.0;README 同步更新
Co-Authored-By: WorkBuddy <noreply@workbuddy.ai>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
/**
|
|
* whitespace 留白主题 - lightgallery 灯箱
|
|
* 动态模式:扫描带 data-lightbox 属性的容器内的图片,点击放大预览。
|
|
*/
|
|
import lightGallery from "lightgallery";
|
|
import lgZoom from "lightgallery/plugins/zoom";
|
|
import "lightgallery/css/lightgallery.css";
|
|
import "lightgallery/css/lg-zoom.css";
|
|
|
|
export function initLightbox(): void {
|
|
const containers = document.querySelectorAll<HTMLElement>("[data-lightbox]");
|
|
if (!containers.length) return;
|
|
|
|
containers.forEach((container) => {
|
|
const images = Array.from(container.querySelectorAll("img"));
|
|
if (!images.length) return;
|
|
|
|
const items = images
|
|
.map((img) => {
|
|
const src = img.getAttribute("data-full") || img.currentSrc || img.src;
|
|
if (!src) return null;
|
|
return { src, thumb: src, alt: img.alt || "" };
|
|
})
|
|
.filter((item): item is { src: string; thumb: string; alt: string } =>
|
|
Boolean(item),
|
|
);
|
|
if (!items.length) return;
|
|
|
|
// 挂载到 body,避免父级 stacking context 遮挡灯箱
|
|
const gallery = lightGallery(document.body, {
|
|
dynamic: true,
|
|
dynamicEl: items,
|
|
plugins: [lgZoom],
|
|
speed: 400,
|
|
});
|
|
|
|
images.forEach((img, index) => {
|
|
img.style.cursor = "zoom-in";
|
|
img.addEventListener("click", (e) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
gallery.openGallery(index);
|
|
});
|
|
});
|
|
});
|
|
}
|