fix(ref): 网络图保留 URL 输入行(缓存成 localRef 后仍可改链接)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m5s

This commit is contained in:
qiqi committed 2026-12-04 15:25:09 +08:00
1 parent ab15ea3a93
commit c8a332fdac
3 files changed
+15 -7

No files matched your search

+10 -5
View File
@@ -691,13 +691,17 @@
// 直接 String() 会变成 "[object Object]" ⇒ <img> 破图(2026-11-29 实测 45 个节点踩中)。
const src = wResolveImg(d.localRef) || wResolveImg(d.data) || wResolveImg(d.url)
const hasImg = !!src
// 来源判定:url 是 http(s) 就是网络图(缓存出 localRef 也不改变来源);否则是本地图片。
const remoteUrl = typeof d.url === 'string' && /^https?:\/\//i.test(d.url)
const showUrlRow = remoteUrl || !(d.data || d.localRef || d.localName)
const commitRefUrl = (event) => {
const root = event && event.currentTarget && event.currentTarget.closest ? event.currentTarget.closest('.iwb-ref-body') : null
const input = root && root.querySelector('.iwb-ref-url-input')
const value = String((input && input.value) || '').trim()
if (!value) return
if (!/^https?:\/\//i.test(value)) return props.onNotice && props.onNotice('图片链接必须以 http:// 或 https:// 开头')
onUpdate(node.id, { url: value, data: null, localName: null, name: value.split('/').pop().split('?')[0] || '远程图片' })
// 2026-12-05:换 URL 要一并清掉旧网络图的本地缓存引用,否则仍显示上一张。
onUpdate(node.id, { url: value, data: null, localRef: null, ref: null, localName: null, name: value.split('/').pop().split('?')[0] || '远程图片' })
}
// 序号徽标:全画布参考图节点按坐标排序中的位置(x 从左到右,同 x 按 y)
const allRefs = (props.nodes || []).filter((n) => n.type === 'ref' && !(n.data && n.data.enabled === false))
@@ -761,11 +765,12 @@
el('span', { className: 'iwb-ref-upload' }, '点击上传参考图'),
fileInput,
),
// 2026-12-05(用户):URL 输入只在「空节点」和「纯网络图」出现;本地图片完全不渲染这一行。
// 2026-12-05(用户):URL 输入行保留给「网络图」与「空节点」;本地图片不渲染。
// 网络图被后台缓存成 localRef 之后仍要能改链接(原来一看 localRef 就藏起来,用户找不到输入框)。
// 「上传到图库」在选中气泡里,行内只有输入框。
(d.data || d.localRef || d.localName) ? null : el('div', { className: 'iwb-ref-url-row' },
el('input', { className: 'iwb-input iwb-ref-url-input', defaultValue: (typeof d.url === 'string' && !d.data) ? d.url : '', placeholder: '输入图片 URL(回车使用)', onKeyDown: (e) => { if (e.key === 'Enter') commitRefUrl(e) }, onPointerDown: stop }),
),
showUrlRow ? el('div', { className: 'iwb-ref-url-row' },
el('input', { className: 'iwb-input iwb-ref-url-input', defaultValue: remoteUrl ? d.url : '', placeholder: '输入图片 URL(回车使用)', onKeyDown: (e) => { if (e.key === 'Enter') commitRefUrl(e) }, onPointerDown: stop }),
) : null,
el('div', { className: 'iwb-ref-foot' }, null),
)
}