From bd138b7a7ed468f39a66980481a2520d51eb0fd1 Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 20 Nov 2026 13:32:00 +0800 Subject: [PATCH] =?UTF-8?q?chore(plugin):=20=E5=90=8C=E6=AD=A5=20gallery?= =?UTF-8?q?=201.5.1=20/=20grouplib=201.0.2=20+=20=E5=9B=9E=E5=BD=92?= =?UTF-8?q?=EF=BC=88=E8=83=B6=E5=9B=8A=E6=BB=9A=E5=8A=A8=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E3=80=81.iwb-hint=20=E4=BD=9C=E7=94=A8=E5=9F=9F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/gallery/main.js | 2 +- plugins/gallery/manifest.json | 6 +++--- plugins/gallery/styles.css | 3 ++- plugins/index.json | 12 ++++++------ ...3f7615a.js => plugin-grouplib.0f63972e5c8c.js} | 15 +++++++++------ tests/plugin-gallery-recovery-test.js | 7 +++++++ tests/plugin-grouplib-render-test.js | 4 ++++ 7 files changed, 32 insertions(+), 17 deletions(-) rename plugins/runtime/{plugin-grouplib.084fb3f7615a.js => plugin-grouplib.0f63972e5c8c.js} (97%) diff --git a/plugins/gallery/main.js b/plugins/gallery/main.js index 90d8c30..95e2c02 100644 --- a/plugins/gallery/main.js +++ b/plugins/gallery/main.js @@ -372,7 +372,7 @@ global.IWBPluginHost.register({ id: 'gallery', name: '图库', - version: '1.5.0', + version: '1.5.1', apiVersion: 1, capabilities: ['panels', 'gallery'], data: { schemaVersion: 1, maxBytes: 65536 }, diff --git a/plugins/gallery/manifest.json b/plugins/gallery/manifest.json index 44fd564..d173b2f 100644 --- a/plugins/gallery/manifest.json +++ b/plugins/gallery/manifest.json @@ -1,7 +1,7 @@ { "id": "gallery", "name": "图库", - "version": "1.5.0", + "version": "1.5.1", "apiVersion": 1, "main": "main.js", "style": "styles.css", @@ -13,7 +13,7 @@ "图库" ], "files": { - "main.js": "1b831a6bd2e3ab405a8524294cf422c04ff1bc950d0e2c012e1a686fec77926a", - "styles.css": "94c57b2d18deef3f672242efe1812ba1dc88dad90f03648d68feaa64bc70f572" + "main.js": "83ea7f97379bc9cf9cc70e83b1578b114b37607dccac96fcd729fe8ce0027a42", + "styles.css": "75fb6f379f2c94939e1de98c56082bc5cbef299283e7cc1325e569f3bfdd5f1f" } } diff --git a/plugins/gallery/styles.css b/plugins/gallery/styles.css index 1b997f9..0efd471 100644 --- a/plugins/gallery/styles.css +++ b/plugins/gallery/styles.css @@ -65,4 +65,5 @@ .iwb-history-actions { display: flex; gap: 4px; padding: 4px 2px 0; } .iwb-history-actions .iwb-btn-sm { padding: 1px 6px; font-size: 10px; } .iwb-history-more { display: flex; justify-content: center; padding: 4px 0 2px; } -.iwb-hint { font-size: 11px; color: var(--iwb-text2); text-align: center; padding: 12px 6px; } \ No newline at end of file +/* 只作用于图库自己的空态提示:不加前缀会泄漏到设置页等使用 .iwb-hint 的地方(文字被居中) */ +.iwb-history-embedded .iwb-hint { font-size: 11px; color: var(--iwb-text2); text-align: center; padding: 12px 6px; } \ No newline at end of file diff --git a/plugins/index.json b/plugins/index.json index ec8e215..6f7f66c 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -22,17 +22,17 @@ "dir": "gallery", "main": "main.js", "style": "styles.css", - "version": "1.5.0", + "version": "1.5.1", "files": { - "main.js": "1b831a6bd2e3ab405a8524294cf422c04ff1bc950d0e2c012e1a686fec77926a", - "styles.css": "94c57b2d18deef3f672242efe1812ba1dc88dad90f03648d68feaa64bc70f572" + "main.js": "83ea7f97379bc9cf9cc70e83b1578b114b37607dccac96fcd729fe8ce0027a42", + "styles.css": "75fb6f379f2c94939e1de98c56082bc5cbef299283e7cc1325e569f3bfdd5f1f" } }, { "id": "grouplib", - "file": "plugin-grouplib.084fb3f7615a.js", - "version": "1.0.1", - "integrity": "sha256-CE+z92FarkfIm+AZk3EksCKRee/Nf8dqB/zNNe+7iHg=" + "file": "plugin-grouplib.0f63972e5c8c.js", + "version": "1.0.2", + "integrity": "sha256-D2OXLlyMDZecVN1XpGgLHX66mfY15j0YHMoPyBIi1U0=" }, { "id": "image-annotate", diff --git a/plugins/runtime/plugin-grouplib.084fb3f7615a.js b/plugins/runtime/plugin-grouplib.0f63972e5c8c.js similarity index 97% rename from plugins/runtime/plugin-grouplib.084fb3f7615a.js rename to plugins/runtime/plugin-grouplib.0f63972e5c8c.js index a8dfc6b..dda190a 100644 --- a/plugins/runtime/plugin-grouplib.084fb3f7615a.js +++ b/plugins/runtime/plugin-grouplib.0f63972e5c8c.js @@ -281,8 +281,11 @@ } fixed.appendChild(topRow) - // 分类胶囊 + // 分类胶囊:宿主的 .iwb-lib-chips-scroll 负责「单行 + 横向滚动 + 右侧渐隐」, + // 直接铺在 .iwb-lib-chips 里会被 nowrap 裁掉(分组多时右侧分类看不见) var chips = el('div', { class: 'iwb-lib-chips' }) + var chipsScroll = el('div', { class: 'iwb-lib-chips-scroll' }) + chips.appendChild(chipsScroll) function chip (label, value, count, extra) { var b = el('button', { class: 'iwb-chip' + (filter === value ? ' iwb-chip-active' : '') + (extra || ''), title: value === '__none__' ? '未分组;拖拽节点组卡片到此 = 移出分组' : (value === 'all' ? '' : '拖拽节点组卡片到此 = 移动到该分组') }) b.appendChild(document.createTextNode(label)) @@ -297,15 +300,15 @@ }) return b } - chips.appendChild(chip('全部', 'all', list.length)) - chips.appendChild(chip('未分组', '__none__', countOf('__none__'), ' iwb-chip-drop')) + chipsScroll.appendChild(chip('全部', 'all', list.length)) + chipsScroll.appendChild(chip('未分组', '__none__', countOf('__none__'), ' iwb-chip-drop')) gs.forEach(function (g) { chips.appendChild(chip(g.name, g.name, countOf(g.name), ' iwb-chip-drop')) }) var addChip = el('button', { class: 'iwb-chip iwb-chip-add', title: '新建分组', text: '+' }) addChip.addEventListener('click', function () { newOpen = !newOpen; render() }) - chips.appendChild(addChip) + chipsScroll.appendChild(addChip) var mgChip = el('button', { class: 'iwb-chip iwb-chip-add', title: '管理分组(重命名 / 排序 / 删除)', text: '⚙' }) mgChip.addEventListener('click', openManager) - chips.appendChild(mgChip) + chipsScroll.appendChild(mgChip) fixed.appendChild(chips) if (newOpen) { @@ -432,7 +435,7 @@ global.IWBPluginHost.register({ id: 'grouplib', name: '节点组', - version: '1.0.1', + version: '1.0.2', apiVersion: 1, capabilities: ['panels', 'grouplib'], data: { schemaVersion: 1, maxBytes: 65536 }, diff --git a/tests/plugin-gallery-recovery-test.js b/tests/plugin-gallery-recovery-test.js index 71f4c9c..cea9593 100644 --- a/tests/plugin-gallery-recovery-test.js +++ b/tests/plugin-gallery-recovery-test.js @@ -13,6 +13,13 @@ const { JSDOM } = require('jsdom') const src = fs.readFileSync(path.resolve(__dirname, '..', '..', 'iwb-plugins-desktop', 'gallery', 'src', 'index.js'), 'utf8') // 插件自带样式:图标按钮无外框、工具组横排,靠这份 CSS 保证(不依赖客户端 style.css) const pluginCss = fs.readFileSync(path.resolve(__dirname, '..', '..', 'iwb-plugins-desktop', 'gallery', 'styles.css'), 'utf8') +// 插件样式会注入到整页:不允许出现未限定作用域的 .iwb-hint(会把设置页说明文字变成居中) +assertNoGlobalHint() +function assertNoGlobalHint () { + const bad = pluginCss.split('\n').filter((line) => /^\.iwb-hint\s*\{/.test(line.trim())) + if (bad.length) throw new Error('图库 styles.css 存在未限定作用域的 .iwb-hint:' + bad.join(' / ')) + if (pluginCss.indexOf('.iwb-history-embedded .iwb-hint') < 0) throw new Error('图库 styles.css 应把 .iwb-hint 限定在 .iwb-history-embedded 下') +} const wait = (ms) => new Promise((r) => setTimeout(r, ms)) diff --git a/tests/plugin-grouplib-render-test.js b/tests/plugin-grouplib-render-test.js index 09c188e..7bbcc01 100644 --- a/tests/plugin-grouplib-render-test.js +++ b/tests/plugin-grouplib-render-test.js @@ -57,6 +57,10 @@ const wait = (ms) => new Promise((r) => setTimeout(r, ms)) const cards = () => Array.from(host.querySelectorAll('.iwb-pcard')) assert.strictEqual(cards().length, 2, '应渲染两个节点组卡片,实际 ' + cards().length) + // 胶囊必须在横向滚动容器里(否则分组多了右侧分类被裁掉) + const chipsWrap = host.querySelector('.iwb-lib-chips') + assert.ok(chipsWrap && chipsWrap.querySelector('.iwb-lib-chips-scroll'), '胶囊行应有 .iwb-lib-chips-scroll 滚动容器') + assert.ok(chipsWrap.querySelector('.iwb-lib-chips-scroll .iwb-chip'), '胶囊应放在滚动容器内') const chips = Array.from(host.querySelectorAll('.iwb-chip')).map((c) => c.textContent) assert.ok(chips.some((t) => t.indexOf('全部') === 0 && /2$/.test(t)), '应有「全部 2」胶囊:' + chips.join('|')) assert.ok(chips.some((t) => t.indexOf('未分组') === 0 && /1$/.test(t)), '应有「未分组 1」胶囊:' + chips.join('|'))