feat(promptlib,gallery): promptlib 1.9.0 单条分享/导入分享;gallery 1.6.12 打开本地目录
validate / validate (push) Canceled after 0s
validate / validate (push) Canceled after 0s
This commit is contained in:
1 parent
27a641903c
commit
2d2738f3a1
5 files changed
+121
-10
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/gallery",
|
||||
"private": true,
|
||||
"version": "1.6.11",
|
||||
"version": "1.6.12",
|
||||
"description": "图库:右栏图片墙(筛选/多选/预览/插入画布/下载/删除),数据由宿主 gallery 能力提供",
|
||||
"ibwPlugin": {
|
||||
"id": "gallery",
|
||||
|
||||
+14
-2
@@ -129,8 +129,20 @@
|
||||
setBtn.setAttribute('aria-expanded', 'false')
|
||||
var settings = el('div', { class: 'iwb-gal-settings', role: 'dialog', 'aria-label': '图库设置' })
|
||||
settings.style.display = 'none'
|
||||
// 2026-11-24:底栏加「打开本地图库目录」图标(文件夹),放在设置图标左边;只桌面端可用。
|
||||
var folderBtn = iconBtn('打开本地目录', function (svg) {
|
||||
svgPath(svg, 'M2 4.5h4l1.5 2H14v6.5H2z')
|
||||
}, '在系统文件管理器里打开本地图库目录(images/gallery)')
|
||||
folderBtn.addEventListener('click', function (e) {
|
||||
e.stopPropagation()
|
||||
if (!ctx.gallery || typeof ctx.gallery.openFolder !== 'function') { setStatus('仅桌面端可打开本地目录'); return }
|
||||
Promise.resolve(ctx.gallery.openFolder()).then(function (r) {
|
||||
if (r && r.ok === false) setStatus('打开失败:' + ((r && r.error) || '仅桌面端可用'))
|
||||
}).catch(function (err) { setStatus('打开失败:' + ((err && err.message) || err)) })
|
||||
})
|
||||
folderBtn.style.display = (typeof window !== 'undefined' && window.__TAURI__ && window.__TAURI__.core) ? '' : 'none'
|
||||
// v1.4.2:刷新与设置同放右侧工具组(此前刷新在左侧信息区,空间不足时会向右溢出、压住设置图标)
|
||||
var tools = el('div', { class: 'iwb-gal-tools' }, refreshBtn, setBtn)
|
||||
var tools = el('div', { class: 'iwb-gal-tools' }, refreshBtn, folderBtn, setBtn)
|
||||
var foot = el('div', { class: 'iwb-gal-foot' },
|
||||
el('div', { class: 'iwb-gal-foot-left' }, countEl, pickedEl, failEl, statusEl), tools)
|
||||
var wrap = el('div', { class: 'iwb-history-embedded' }, [head, grid, more, empty, foot, settings])
|
||||
@@ -543,7 +555,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'gallery',
|
||||
name: '图库',
|
||||
version: '1.6.11',
|
||||
version: '1.6.12',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'gallery'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@iwb-plugin/promptlib",
|
||||
"private": true,
|
||||
"version": "1.8.24",
|
||||
"version": "1.9.0",
|
||||
"description": "提示词库:右栏提示词列表(搜索/分组/收藏/新建编辑/插入画布/复制/删除),数据由宿主 promptlib 能力提供",
|
||||
"ibwPlugin": {
|
||||
"id": "promptlib",
|
||||
|
||||
+100
-3
@@ -151,6 +151,25 @@
|
||||
return 'promptlib-backup-' + d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0') + '.json'
|
||||
}
|
||||
|
||||
// 单条提示词分享(2026-11-24):文本带前缀,可直接粘到聊天软件;导入两种都认(带前缀 / 纯 JSON)。
|
||||
var SHARE_TAG = 'IWB-PROMPT-SHARE'
|
||||
function plpParseShare (raw) {
|
||||
var t = String(raw || '').trim()
|
||||
if (t.indexOf(SHARE_TAG) === 0) t = t.slice(SHARE_TAG.length).trim()
|
||||
var obj = null
|
||||
try { obj = JSON.parse(t) } catch (e) { return null }
|
||||
var item = obj && (obj.kind === 'prompt-share' ? obj.sharing : (obj.sharing || (obj.text ? obj : null)))
|
||||
if (!item || typeof item.text !== 'string' || !item.text.trim()) return null
|
||||
return item
|
||||
}
|
||||
function plpSharePayload (p) {
|
||||
return plpCoverUrl(p).then(function (cv) {
|
||||
var body = { app: 'image-workbench', kind: 'prompt-share', version: 1, sharing: { name: p.name || '', text: p.text || '', vars: detectVars(p.text || ''), group: p.group || '', tags: p.tags || [] } }
|
||||
if (cv && cv.length < 300000) body.sharing.cover = cv
|
||||
return SHARE_TAG + '\n' + JSON.stringify(body)
|
||||
})
|
||||
}
|
||||
|
||||
function renderPluginSettings () {
|
||||
var root = el('div', { class: 'iwb-plp-settings' })
|
||||
var state = { prompts: [], groups: [] }
|
||||
@@ -283,7 +302,31 @@
|
||||
})
|
||||
}).catch(function (e) { impBtn.disabled = false; status.textContent = '导入失败:' + ((e && e.message) || e) })
|
||||
})
|
||||
s2.appendChild(el('div', { class: 'iwb-plp-sbtns' }, expBtn, impBtn))
|
||||
var impShareBtn = el('button', { class: 'iwb-btn iwb-btn-sm', title: '读取剪贴板里别人分享的单条提示词', text: '导入分享…' })
|
||||
impShareBtn.addEventListener('click', function () {
|
||||
impShareBtn.disabled = true; status.textContent = '读取剪贴板…'
|
||||
Promise.resolve(PLP_CTX.promptlib.paste && PLP_CTX.promptlib.paste()).then(function (r) {
|
||||
impShareBtn.disabled = false
|
||||
if (!r || r.ok === false) { status.textContent = '读取剪贴板失败'; return null }
|
||||
var item = plpParseShare(r.text)
|
||||
if (!item) { status.textContent = '剪贴板里没有可识别的提示词分享'; return null }
|
||||
var name = String(item.name || '').trim() || ('导入的提示词 ' + String(item.text).slice(0, 8) + '…')
|
||||
state.prompts = state.prompts.concat([{ id: 'q' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6), name: name, text: item.text, group: String(item.group || ''), tags: item.tags || [], vars: detectVars(item.text) }])
|
||||
var g2 = String(item.group || '').trim()
|
||||
if (g2 && !state.groups.some(function (x) { return x.name === g2 })) state.groups = state.groups.concat([{ id: g2, name: g2 }])
|
||||
return save()
|
||||
}).then(function (r2) {
|
||||
if (!r2) return
|
||||
return PLP_CTX.promptlib.list().then(function (cur) {
|
||||
state.prompts = (cur && cur.prompts) || state.prompts
|
||||
state.groups = (cur && cur.groups) || state.groups
|
||||
paint(); refreshUsage()
|
||||
status.textContent = '已导入分享'
|
||||
plpNotify('已导入分享的提示词')
|
||||
})
|
||||
}).catch(function (e) { impShareBtn.disabled = false; status.textContent = '导入失败:' + ((e && e.message) || e) })
|
||||
})
|
||||
s2.appendChild(el('div', { class: 'iwb-plp-sbtns' }, expBtn, impBtn, impShareBtn))
|
||||
s2.appendChild(el('label', { class: 'iwb-plp-sopt' }, overwrite, el('span', { text: '导入时覆盖同名条目' })))
|
||||
s2.appendChild(status)
|
||||
root.appendChild(s2)
|
||||
@@ -658,6 +701,9 @@
|
||||
var ed = el('button', { class: 'iwb-ctx-item', text: '编辑…' })
|
||||
ed.addEventListener('click', function () { closeMenu(); openEditModal(p, false) })
|
||||
menu.appendChild(ed)
|
||||
var sh = el('button', { class: 'iwb-ctx-item', text: '分享…' })
|
||||
sh.addEventListener('click', function () { closeMenu(); doShare(p) })
|
||||
menu.appendChild(sh)
|
||||
document.body.appendChild(menu)
|
||||
menuEl = menu
|
||||
setTimeout(function () { document.addEventListener('pointerdown', onDocDown, true) }, 0)
|
||||
@@ -1254,9 +1300,47 @@
|
||||
if (c.img && FILEAPI) return Promise.resolve(FILEAPI.get(String(c.img))).then(function (r) { return (r && r.ok && r.url) || '' }).catch(function () { return '' })
|
||||
return Promise.resolve('')
|
||||
}
|
||||
// ===== 2026-11-24:单条提示词分享 / 导入别人的分享 =====
|
||||
// 分享格式刻意做成「可读的 JSON 文本」,直接粘到微信/QQ 也能看懂;导入时两种都认:
|
||||
// ① 带 IWB-PROMPT 头的整段文本 ② 直接是 {kind:'prompt-share'} 的 JSON
|
||||
function sharePayload (p) {
|
||||
return coverToDataUrl(p).then(function (cv) {
|
||||
var body = { app: 'image-workbench', kind: 'prompt-share', version: 1, sharing: { name: p.name || '', text: p.text || '', vars: varsOf(p), group: p.group || '', tags: p.tags || [] } }
|
||||
if (cv && cv.length < 300000) body.sharing.cover = cv
|
||||
return SHARE_TAG + '\n' + JSON.stringify(body)
|
||||
})
|
||||
}
|
||||
function doShare (p) {
|
||||
if (!p) return
|
||||
sharePayload(p).then(function (text) {
|
||||
return Promise.resolve(api.copy(text)).then(function (r) {
|
||||
if (r && r.ok === false) { notify('分享失败:' + ((r && r.error) || '剪贴板不可用'), 'err'); return }
|
||||
notify('已复制分享内容,粘贴给对方即可')
|
||||
})
|
||||
}).catch(function (e) { notify('分享失败:' + ((e && e.message) || e), 'err') })
|
||||
}
|
||||
function doImportShare () {
|
||||
return Promise.resolve(api.paste && api.paste()).then(function (r) {
|
||||
if (!r || r.ok === false) { notify('读取剪贴板失败:' + ((r && r.error) || '剪贴板不可用'), 'err'); return { ok: false } }
|
||||
var item = plpParseShare(r.text)
|
||||
if (!item) { notify('剪贴板里没有可识别的提示词分享', 'err'); return { ok: false, error: 'no-share' } }
|
||||
var name = String(item.name || '').trim() || ('导入的提示词 ' + String(item.text).slice(0, 8) + '…')
|
||||
var incoming = normalize({ id: uid('q'), name: name, text: item.text, group: String(item.group || ''), tags: item.tags || [] })
|
||||
var cv = item.cover
|
||||
var ready = (typeof cv === 'string' && cv.indexOf('data:') === 0 && FILEAPI)
|
||||
? Promise.resolve(FILEAPI.put(hashName(cv) + '.jpg', cv)).then(function (res) { return res && res.ok ? Object.assign({}, incoming, { cover: { img: hashName(cv) + '.jpg' } }) : incoming }).catch(function () { return incoming })
|
||||
: Promise.resolve(incoming)
|
||||
return ready.then(function (p2) {
|
||||
prompts = prompts.concat([p2])
|
||||
return persist().then(function () { render(); notify('已导入分享:' + (p2.name || '')); return { ok: true, name: p2.name } })
|
||||
})
|
||||
}).catch(function (e) { notify('导入失败:' + ((e && e.message) || e), 'err'); return { ok: false } })
|
||||
}
|
||||
|
||||
function openBackup () {
|
||||
var exportBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-btn-primary', text: '导出备份…' })
|
||||
var importBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '导入备份…' })
|
||||
var importShareBtn = el('button', { class: 'iwb-btn iwb-btn-sm', title: '读取剪贴板里的单条提示词分享并加入提示词库', text: '导入分享…' })
|
||||
var overwrite = el('input', { type: 'checkbox' })
|
||||
var status = el('div', { class: 'iwb-hint', text: '' })
|
||||
openDialog({
|
||||
@@ -1276,6 +1360,7 @@
|
||||
bodyEl.appendChild(box)
|
||||
footEl.appendChild(exportBtn)
|
||||
footEl.appendChild(importBtn)
|
||||
footEl.appendChild(importShareBtn)
|
||||
exportBtn.addEventListener('click', function () {
|
||||
exportBtn.disabled = true
|
||||
status.textContent = '正在导出…'
|
||||
@@ -1296,6 +1381,16 @@
|
||||
else { status.textContent = '导出失败:' + ((r && r.error) || '未知错误'); notify('导出失败', 'err') }
|
||||
}).catch(function (e) { exportBtn.disabled = false; status.textContent = '导出失败:' + ((e && e.message) || e); notify('导出失败', 'err') })
|
||||
})
|
||||
importShareBtn.addEventListener('click', function () {
|
||||
importShareBtn.disabled = true
|
||||
status.textContent = '读取剪贴板…'
|
||||
doImportShare().then(function (r) {
|
||||
importShareBtn.disabled = false
|
||||
if (r && r.ok) status.textContent = '已导入分享:' + (r.name || '')
|
||||
else if (r && r.error === 'no-share') status.textContent = '剪贴板里没有可识别的提示词分享'
|
||||
else status.textContent = '导入失败'
|
||||
}).catch(function (e) { importShareBtn.disabled = false; status.textContent = '导入失败:' + ((e && e.message) || e) })
|
||||
})
|
||||
importBtn.addEventListener('click', function () {
|
||||
importBtn.disabled = true
|
||||
status.textContent = '等待选择文件…'
|
||||
@@ -1411,6 +1506,8 @@
|
||||
})
|
||||
})
|
||||
cp.addEventListener('click', function () { Promise.resolve(api.copy(filled())).then(function (r) { if (r && r.ok === false) notify('复制失败', 'err'); else notify('已复制全文') }) })
|
||||
var share = el('button', { class: 'iwb-btn iwb-btn-sm', title: '复制这条提示词的分享内容,粘贴给对方即可导入', text: '分享' })
|
||||
share.addEventListener('click', function () { doShare(p) })
|
||||
ins.addEventListener('click', function () { dlg.close(); beginPlacement('prompt', { text: filled(), name: p.name || '' }) })
|
||||
var insImg = null
|
||||
if (p.cover) {
|
||||
@@ -1425,7 +1522,7 @@
|
||||
}).catch(function () { notify('插入封面失败', 'err') })
|
||||
})
|
||||
}
|
||||
footEl.appendChild(del); footEl.appendChild(el('span', { class: 'iwb-drawer-spacer' })); if (insTpl) footEl.appendChild(insTpl); footEl.appendChild(cp)
|
||||
footEl.appendChild(del); footEl.appendChild(el('span', { class: 'iwb-drawer-spacer' })); if (insTpl) footEl.appendChild(insTpl); footEl.appendChild(cp); footEl.appendChild(share)
|
||||
if (insImg) footEl.appendChild(insImg)
|
||||
footEl.appendChild(ins)
|
||||
},
|
||||
@@ -1763,7 +1860,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'promptlib',
|
||||
name: '提示词库',
|
||||
version: '1.8.24',
|
||||
version: '1.9.0',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'],
|
||||
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
|
||||
|
||||
@@ -178,9 +178,11 @@
|
||||
|
||||
/* v1.5.10:设置页 */
|
||||
.iwb-plp-settings{display:flex;flex-direction:column;gap: 16px}
|
||||
.iwb-plp-ssec{border:1px solid var(--iwb-border,#e3e5e9);border-radius:12px;padding: 12px 12px;display:flex;flex-direction:column;gap:8px}
|
||||
.iwb-plp-stitle{font-weight:600;font-size: 13px}
|
||||
.iwb-plp-sgroups{display:flex;flex-direction:column;border:1px solid var(--iwb-border,#eef0f2);border-radius:10px;overflow:hidden}
|
||||
/* 2026-11-24:插件设置页跟随宿主的设置分组 token(不再自画卡片,避免卡片套卡片) */
|
||||
.iwb-plp-ssec{border:0;border-top:1px solid var(--iwb-set-divider,var(--iwb-border,#e3e5e9));border-radius:0;padding:var(--iwb-space-12) 0 0;display:flex;flex-direction:column;gap:var(--iwb-space-8)}
|
||||
.iwb-plp-ssec:first-child{border-top:0;padding-top:0}
|
||||
.iwb-plp-stitle{font-weight:600;font-size:var(--iwb-font-md,13px);color:var(--iwb-text,#2a2f36)}
|
||||
.iwb-plp-sgroups{display:flex;flex-direction:column;border:1px solid var(--iwb-set-input-border,var(--iwb-border,#eef0f2));border-radius:var(--iwb-radius-card,10px);overflow:hidden}
|
||||
.iwb-plp-sgrow{display:flex;align-items:center;gap:8px;padding: 6px 10px;border-top:1px solid var(--iwb-border,#f1f3f5)}
|
||||
.iwb-plp-sgrow:first-child{border-top:0}
|
||||
.iwb-plp-sgrip{width:12px;height:12px;background:radial-gradient(var(--iwb-text2,#c2c7cf) 1px,transparent 1px);background-size:4px 4px;border-radius: 6px;flex:0 0 auto}
|
||||
|
||||
Reference in new issue
Block a user