diff --git a/plugins/index.json b/plugins/index.json index 73bc951..e7ea9e4 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -44,9 +44,9 @@ "dir": "promptlib", "main": "main.js", "style": "styles.css", - "version": "1.6.19", + "version": "1.6.20", "files": { - "main.js": "541fd18a8f34a8d3720b96f27e2e0ce278a6361f650f4f52a68664e560fc7139", + "main.js": "65c4a90eba49eef00caf1048da7a8e8fa543c565b8f2d796aedf6e0c3ffbfa72", "styles.css": "1fdad04e2ffe1c8ba2a991a88072f780b65238096f9ccd1b5adba671ff2c9cb3" } }, diff --git a/plugins/promptlib/main.js b/plugins/promptlib/main.js index dfc4153..b738c0e 100644 --- a/plugins/promptlib/main.js +++ b/plugins/promptlib/main.js @@ -1321,7 +1321,17 @@ insImg.addEventListener('click', function () { var covName = coverNameOf(p) var covData = (covName && FILEAPI) ? Promise.resolve(FILEAPI.get(covName)).then(function (x) { return x && x.ok ? x.url : '' }).catch(function () { return '' }) : Promise.resolve(typeof p.cover === 'string' ? p.cover : '') - covData.then(function (u) { return api.insertImage(u, p.name || '') }).then(function (r) { + covData.then(function (u) { + if (!u) return { ok: false, error: '封面文件读取失败(可能文件已丢失)' } + // 优先用画布写入能力直接建参考图节点(不依赖 promptlib.insertImage 的宿主实现) + var cwImg = ctx.canvasWrite || ctx.canvas + if (cwImg && typeof cwImg.createImageNode === 'function') { + var ctr = canvasCenter(280, 180) + var nid = cwImg.createImageNode({ dataUrl: u, name: p.name || '封面图片', x: ctr ? ctr.x : undefined, y: ctr ? ctr.y : undefined }) + return nid ? { ok: true } : { ok: false, error: '插入封面失败' } + } + return api.insertImage(u, p.name || '') + }).then(function (r) { if (r && r.ok === false) { notify((r && r.error) || '插入封面失败', 'err'); return } notify('已插入封面图片') dlg.close() @@ -1594,7 +1604,7 @@ global.IWBPluginHost.register({ id: 'promptlib', name: '提示词库', - version: '1.6.19', + version: '1.6.20', apiVersion: 1, capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite'], data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 }, diff --git a/plugins/promptlib/manifest.json b/plugins/promptlib/manifest.json index 9757210..29516d1 100644 --- a/plugins/promptlib/manifest.json +++ b/plugins/promptlib/manifest.json @@ -1,7 +1,7 @@ { "id": "promptlib", "name": "提示词库", - "version": "1.6.19", + "version": "1.6.20", "apiVersion": 1, "main": "main.js", "style": "styles.css", @@ -13,7 +13,7 @@ "提示词" ], "files": { - "main.js": "541fd18a8f34a8d3720b96f27e2e0ce278a6361f650f4f52a68664e560fc7139", + "main.js": "65c4a90eba49eef00caf1048da7a8e8fa543c565b8f2d796aedf6e0c3ffbfa72", "styles.css": "1fdad04e2ffe1c8ba2a991a88072f780b65238096f9ccd1b5adba671ff2c9cb3" } }