From 6c598e389881dcfba39a125f7ef6c7fb1e636ae3 Mon Sep 17 00:00:00 2001 From: qiqi Date: Sat, 28 Nov 2026 01:37:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(gallery):=201.8.1=20=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E6=87=92=E5=8A=A0=E8=BD=BD=EF=BC=881.8.0=20=E8=AE=A9=E5=A4=A7?= =?UTF-8?q?=E9=87=8F=E5=8D=A1=E7=89=87=E6=B0=B8=E8=BF=9C=E5=81=9C=E5=9C=A8?= =?UTF-8?q?=E3=80=8C=E5=8A=A0=E8=BD=BD=E4=B8=AD=E2=80=A6=E3=80=8D=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E5=8F=8C=E5=87=BB=E6=94=B9=E4=BA=8B=E4=BB=B6=E5=A7=94?= =?UTF-8?q?=E6=89=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户反馈 1.8.0 之后:图库加载不完、双击打不开、卡片被窗口裁掉。 - 懒加载撤销:IntersectionObserver 在停靠栏里不稳定 —— 部分卡片(尤其右列)永远收不到 intersecting, 一直停在「加载中…」,没有 也就没有点击/双击目标。改回同步取缩略图(同 1.7.5 行为)。 - 双击改为在 grid 上事件委托(按 data-name 处理),不再依赖某张 存活; 即使卡片被重绘替换,双击仍能打开预览。 - pick() 里补一次 measure():面板被拖窄后列数会停在旧值上,卡片被窗口裁掉(1.8.0 取消整格重绘后失去了这个副作用修复)。 - 保留 1.8.0 的两个改进:选中只改 class(不整格重绘、不跳顶)、重排前后恢复 scrollTop。 --- plugins/gallery/main.js | 40 +++++++++++++++-------------------- plugins/gallery/manifest.json | 4 ++-- plugins/index.json | 6 +++--- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/plugins/gallery/main.js b/plugins/gallery/main.js index 3a6ddf4..3832eea 100644 --- a/plugins/gallery/main.js +++ b/plugins/gallery/main.js @@ -340,7 +340,6 @@ } function renderGrid () { - if (io) { try { io.disconnect() } catch (e) { /* ignore */ } } clear(grid) var gap = 6 // 每次重排都重新量一次宽度:面板显隐/停靠栏展开时 gridW 可能是旧值, @@ -380,22 +379,6 @@ } // ── v1.8.0:懒加载观察器 / 滚动位置保持 / 选中态就地更新 ───────────────── - var io = null - function ensureIO () { - if (io || typeof global.IntersectionObserver !== 'function') return io - io = new global.IntersectionObserver(function (list) { - for (var i = 0; i < list.length; i++) { - var e = list[i] - if (!e || !e.isIntersecting) continue - var node = e.target - try { io.unobserve(node) } catch (err) { /* ignore */ } - var fn = node && node.__iwbBoot - node.__iwbBoot = null - if (typeof fn === 'function') fn() - } - }, { root: null, rootMargin: '300px 0px' }) - return io - } // 找到真正滚动的祖先(grid 自己在 .iwb-history 里滚),用于重排后恢复位置 function scrollerOf () { var p = grid && grid.parentNode @@ -467,7 +450,6 @@ fail('缩略图加载失败(点击重试)') }) img.addEventListener('click', function (e) { pick(it.name, !!(e && e.shiftKey)) }) - img.addEventListener('dblclick', function () { ctx.gallery.preview(it.name) }) img.addEventListener('dragstart', function (e) { try { var names = (picked[it.name] && count() > 1) ? pickedNames() : [it.name] @@ -498,11 +480,8 @@ } // v1.8.0:缩略图按可见性懒加载(IntersectionObserver,上下预取 300px)—— // 原来一次性对全部条目发 IPC 取缩略图,列表一长首屏就慢。 - box.__iwbBoot = boot - var io0 = ensureIO() - // 前 30 张仍然同步取(首屏 / e2e 需要立刻可见),其余按可见性懒加载 - if (!io0 || Number(seq) < 30) boot() - else io0.observe(box) + // v1.8.1:撤销懒加载——IntersectionObserver 在停靠栏里不稳定,大量卡片停在「加载中…」 + boot() box.addEventListener('contextmenu', function (e) { openMenu(e, it) }) var acts = el('div', { class: 'iwb-history-actions' }) function act (label, title, fn) { @@ -546,12 +525,27 @@ }).catch(function () { setStatus('下载失败,可再点一次重试') }) } + // v1.8.1:双击打开改成在 grid 上做事件委托 —— 原来监听在 上,一旦卡片被重绘替换, + // dblclick 就永远落不到同一个元素(用户反馈「双击打不开」)。委托到容器后按 data-name 处理。 + grid.addEventListener('dblclick', function (e) { + var node = e.target + while (node && node !== grid && !(node.getAttribute && node.getAttribute('data-name'))) node = node.parentNode + if (!node || node === grid) return + var nm = node.getAttribute('data-name') + if (!nm) return + e.preventDefault() + e.stopPropagation() + try { ctx.gallery.preview(nm) } catch (err) { /* ignore */ } + }) + function pick (name, shift) { if (shift) { if (picked[name]) delete picked[name]; else picked[name] = 1 } else { picked = {}; picked[name] = 1 } // v1.8.0:选中只就地改 class/勾选角标 —— 原来整个网格重建,滚动条被顶回顶部, // 而且正在双击的那张 被换掉,双击因此经常打不开。 syncSelection() renderHead() + // 顺手量一次宽度:面板被拖窄后如果没有其它触发条件,列数会停在旧值上(卡片被窗口裁掉) + try { measure() } catch (e) { /* ignore */ } } function syncSelection () { var managed = !!count() diff --git a/plugins/gallery/manifest.json b/plugins/gallery/manifest.json index 90a2367..f68deb4 100644 --- a/plugins/gallery/manifest.json +++ b/plugins/gallery/manifest.json @@ -1,7 +1,7 @@ { "id": "gallery", "name": "图库", - "version": "1.8.0", + "version": "1.8.1", "apiVersion": 1, "main": "main.js", "style": "styles.css", @@ -13,7 +13,7 @@ "图库" ], "files": { - "main.js": "39a93d36a9294c183136e20f90c8c8885a67ada6adc1602b334836cfcba0e15d", + "main.js": "6dd3bf43dce74236d4904c4e33639772ef03bd4cd80d6e5a4532ff7ca7ed085a", "styles.css": "14d374b5d0e1461cb1ca2b125865e9c27df7c3bd79c11caa0afc52152c7d0aef" } } diff --git a/plugins/index.json b/plugins/index.json index edb3fd8..156ded9 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -33,10 +33,10 @@ "dir": "gallery", "main": "main.js", "style": "styles.css", - "version": "1.8.0", + "version": "1.8.1", "files": { - "manifest.json": "3eabd6d707e2154a955049bda895d9c4f32afecaa00df1d9b3e92c92fd4930cd", - "main.js": "39a93d36a9294c183136e20f90c8c8885a67ada6adc1602b334836cfcba0e15d", + "manifest.json": "8e1235f0f0d89d81c9aafe8e4eac4a4dc3521c1b583c845b15595ddeecc7c0c2", + "main.js": "6dd3bf43dce74236d4904c4e33639772ef03bd4cd80d6e5a4532ff7ca7ed085a", "styles.css": "14d374b5d0e1461cb1ca2b125865e9c27df7c3bd79c11caa0afc52152c7d0aef" } },