From d43b1520dcff548ca30a657a791cb7039fce1a1b Mon Sep 17 00:00:00 2001 From: qiqi Date: Wed, 25 Nov 2026 07:34:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(album):=20=E7=82=B9=E5=87=BB=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=AF=BB=E6=9C=80=E6=96=B0=20node=EF=BC=88=E8=BF=9E?= =?UTF-8?q?=E7=82=B9=E6=A8=A1=E5=BC=8F=E5=BC=80=E5=85=B3=E5=A4=B1=E6=95=88?= =?UTF-8?q?=EF=BC=89+=20=E5=8F=AF=E7=82=B9=E5=87=BB=20span=20=E6=8C=A1=20p?= =?UTF-8?q?ointerdown=EF=BC=88=E7=BF=BB=E9=A1=B5/=E5=AF=86=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E5=93=8D=E5=BA=94=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- album/src/index.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/album/src/index.js b/album/src/index.js index 2504673..5b8b405 100644 --- a/album/src/index.js +++ b/album/src/index.js @@ -44,6 +44,13 @@ } return node } + // 可点击元素:宿主在节点体上的 pointerdown 会启动「拖动节点」,单击事件因此被吞。 + // 所有可点击的非 input/button 元素都必须挡住 pointerdown(与 ui-node-bodies 里 stop 的用法一致)。 + function onTap (el0, fn) { + el0.addEventListener('pointerdown', (e) => e.stopPropagation()) + el0.addEventListener('click', (e) => { e.stopPropagation(); fn(e) }) + return el0 + } function hash32 (s) { let h = 0x811c9dc5 const str = String(s || '') @@ -123,9 +130,12 @@ modeLabel.addEventListener('pointerdown', (e) => e.stopPropagation()) modeLabel.addEventListener('click', (e) => { e.stopPropagation() - const d = (node && node.data) || {} + // ⚠ 必须读 st.node(每次 sync 更新),不能读 buildShell 捕获的 node —— + // 那是**挂载时**的旧数据,连点两次会一直算出同一个 next(实测:永远停在批量)。 + const cur = st.node || node + const d = (cur && cur.data) || {} const next = d.albumMode === 'batch' ? 'per-image' : 'batch' - update(props, node, { albumMode: next }) + update(st.props || props, cur, { albumMode: next }) }) const count = el('span', { className: 'iwb-album-count' }) bar.appendChild(modeLabel); bar.appendChild(count) @@ -136,8 +146,7 @@ const seg = el('span', { className: 'iwb-album-seg' }) const segs = {} for (const key of ['S', 'M', 'L']) { - const s = el('span', { title: key === 'S' ? '小格(默认)' : (key === 'M' ? '中格' : '大格') }, key) - s.addEventListener('click', (e) => { e.stopPropagation(); update(props, node, { density: key }) }) + const s = onTap(el('span', { title: key === 'S' ? '小格(默认)' : (key === 'M' ? '中格' : '大格') }, key), () => update(st.props || props, st.node || node, { density: key })) segs[key] = s; seg.appendChild(s) } const tools = el('div', { className: 'iwb-album-tools' }, [btnAdd, btnDir, btnSettle, seg]) @@ -225,10 +234,8 @@ if (showPager) { st.pager.innerHTML = '' const pg = el('span', { className: 'iwb-album-pg' }) - const prev = el('span', { title: '上一页' }, '‹') - const next = el('span', { title: '下一页' }, '›') - prev.addEventListener('click', (e) => { e.stopPropagation(); if (page > 0) update(st.props, st.node, { page: page - 1 }) }) - next.addEventListener('click', (e) => { e.stopPropagation(); if (page < pages - 1) update(st.props, st.node, { page: page + 1 }) }) + const prev = onTap(el('span', { title: '上一页' }, '‹'), () => { if (page > 0) update(st.props, st.node, { page: page - 1 }) }) + const next = onTap(el('span', { title: '下一页' }, '›'), () => { if (page < pages - 1) update(st.props, st.node, { page: page + 1 }) }) pg.appendChild(prev); pg.appendChild(el('b', null, (page + 1) + '/' + pages)); pg.appendChild(next) st.pager.appendChild(pg) const only = el('label', { className: 'iwb-album-mini' }, [