refactor(boundary): 落地状态视图改为注入(src 不再直接读 window 全局);ResultImg 回到纯展示
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m20s

This commit is contained in:
qiqi committed 2026-12-02 19:31:53 +08:00
1 parent c346256115
commit 3a70e16ead
6 files changed
+12 -18

No files matched your search

+4 -13
View File
@@ -8,29 +8,20 @@
const useEffect = React.useEffect
const [hover, setHover] = useState(false)
const item = props.item || {}
// 落地状态(2026-12-02):出图后队列在后台把远程图下到本地;这里只负责把「下载中 / 失败」
// 画出来,并在就绪后换成本地 objectURL(不再让 <img> 直连 CDN,避免慢慢刷/卡半张)。
const view = global.IWBImageIngestView || null
const [, bump] = useState(0)
useEffect(function () { return view ? view.subscribe(function () { bump(function (n) { return n + 1 }) }) : undefined }, [!!view])
const st = view ? view.get(item.url) : null
const src = (st && st.localUrl) ? st.localUrl : item.url
const pending = !!(st && (st.status === 'queued' || st.status === 'downloading'))
const failed = !!(st && st.status === 'failed')
// 2026-12-02:落地状态展示改在输出节点体(ui-node-bodies);本组件全仓无调用点,保持纯展示
const doCopyRef = () => { props.onCopyRef && props.onCopyRef(item.url) }
const doCopyLink = () => {
// 统一走 IWBClipboardCopy(2026-11-24)
try { if (global.IWBClipboardCopy) global.IWBClipboardCopy.copyText(item.url) } catch (e) { /* ignore */ }
}
return el('div', {
className: 'iwb-rimg' + (pending ? ' iwb-rimg-pending' : '') + (failed ? ' iwb-rimg-failed' : ''),
className: 'iwb-rimg',
onMouseEnter: () => setHover(true),
onMouseLeave: () => setHover(false),
},
// 单击只让节点选中(不弹预览),双击才开大图:与输出节点结果图同一手势。
el('img', { className: props.cls || 'iwb-result-thumb', src: src, alt: 'img', loading: 'lazy', title: '双击放大', onClick: (e) => { try { e.stopPropagation() } catch (err) { /* ignore */ } }, onDoubleClick: (e) => { try { e.stopPropagation() } catch (err) { /* ignore */ } if (props.onPreview) props.onPreview(item.url) } }),
pending ? el('div', { className: 'iwb-rimg-flag' }, st.status === 'queued' ? '排队中' : '下载中') : null,
failed ? el('div', { className: 'iwb-rimg-flag iwb-rimg-flag-err' }, '未落地') : null,
el('img', { className: props.cls || 'iwb-result-thumb', src: item.url, alt: 'img', loading: 'lazy', title: '双击放大', onClick: (e) => { try { e.stopPropagation() } catch (err) { /* ignore */ } }, onDoubleClick: (e) => { try { e.stopPropagation() } catch (err) { /* ignore */ } if (props.onPreview) props.onPreview(item.url) } }),
hover ? el('div', { className: 'iwb-rimg-actions' },
el('button', { className: 'iwb-btn iwb-btn-sm', title: '复制为参考图节点', onClick: doCopyRef }, props.copyIcon || '⧉', ' 复制到画布'),
el('button', { className: 'iwb-btn iwb-btn-sm', title: '复制图片链接', onClick: doCopyLink }, '🔗 链接'),