Files
image-workbench-desktop/src/ui-components.js
T

29 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;(function (global) {
'use strict'
const React = global.React
if (!React || !React.createElement) return
const el = React.createElement
function ResultImg(props) {
const useState = React.useState
const [hover, setHover] = useState(false)
const item = props.item || {}
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',
onMouseEnter: () => setHover(true),
onMouseLeave: () => setHover(false),
},
el('img', { className: props.cls || 'iwb-result-thumb', src: item.url, alt: 'img', loading: 'lazy', title: '点击放大', onClick: () => 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 }, '🔗 链接'),
) : null,
)
}
global.IWBResultImg = ResultImg
})(typeof window !== 'undefined' ? window : globalThis)