fix: 修复后台预览工具条显示

This commit is contained in:
Nixevol
2026-07-05 05:22:24 +08:00
parent fee893a716
commit fad5034aab
2 changed files with 15 additions and 3 deletions
+14 -2
View File
@@ -57,6 +57,7 @@ function injectToolbarStyle(): void {
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
transform: translateX(-50%);
backdrop-filter: blur(8px);
pointer-events: auto;
}
.artveris-pswp-toolbar .pswp__button {
position: static;
@@ -211,10 +212,10 @@ function registerToolbarButton(
ariaLabel: options.title,
order: options.order,
isButton: true,
appendTo: 'bar',
appendTo: 'root',
html: options.html,
onInit: (element: HTMLElement, pswp: any) => {
element.parentElement?.classList.add('artveris-pswp-toolbar');
queueMicrotask(() => ensureToolbar(pswp).appendChild(element));
if (!options.imageOnly) return;
const update = () => {
(element as HTMLButtonElement).disabled = !isCurrentImage(pswp);
@@ -227,6 +228,17 @@ function registerToolbarButton(
});
}
function ensureToolbar(pswp: any): HTMLElement {
const root = pswp?.element as HTMLElement | undefined;
let toolbar = root?.querySelector('.artveris-pswp-toolbar') as HTMLElement | null;
if (!toolbar) {
toolbar = document.createElement('div');
toolbar.className = 'artveris-pswp-toolbar pswp__hide-on-close';
root?.appendChild(toolbar);
}
return toolbar;
}
function registerToolbar(lightbox: PhotoSwipeLightbox): void {
injectToolbarStyle();
lightbox.on('uiRegister', () => {