From a4aaa547a763a3c4b0f0239f5f79de9aec830e30 Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 20 Nov 2026 12:59:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(plugin):=20=E7=9B=AE=E5=BD=95=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81=E8=87=AA=E5=B8=A6=20styles.css?= =?UTF-8?q?=EF=BC=88sync=20=E6=8B=B7=E8=B4=9D+manifest.style=EF=BC=89?= =?UTF-8?q?=EF=BC=9Bgallery=201.5.0=20=E4=B8=8A=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main.js} | 4 +- plugins/gallery/manifest.json | 19 ++++++ plugins/gallery/styles.css | 68 +++++++++++++++++++ plugins/index.json | 11 ++- scripts/sync-plugins-from-repo.js | 16 ++++- style.css | 32 +-------- 6 files changed, 114 insertions(+), 36 deletions(-) rename plugins/{runtime/plugin-gallery.ec1dd4a6e21c.js => gallery/main.js} (99%) create mode 100644 plugins/gallery/manifest.json create mode 100644 plugins/gallery/styles.css diff --git a/plugins/runtime/plugin-gallery.ec1dd4a6e21c.js b/plugins/gallery/main.js similarity index 99% rename from plugins/runtime/plugin-gallery.ec1dd4a6e21c.js rename to plugins/gallery/main.js index 2f71cb0..90d8c30 100644 --- a/plugins/runtime/plugin-gallery.ec1dd4a6e21c.js +++ b/plugins/gallery/main.js @@ -198,7 +198,7 @@ function renderGrid () { clear(grid) - var gap = 8 + var gap = 6 var n = Math.max(1, Math.floor((gridW + gap) / (Number(cfg.tile) + gap))) var cols = [] var heights = [] @@ -372,7 +372,7 @@ global.IWBPluginHost.register({ id: 'gallery', name: '图库', - version: '1.4.2', + version: '1.5.0', apiVersion: 1, capabilities: ['panels', 'gallery'], data: { schemaVersion: 1, maxBytes: 65536 }, diff --git a/plugins/gallery/manifest.json b/plugins/gallery/manifest.json new file mode 100644 index 0000000..44fd564 --- /dev/null +++ b/plugins/gallery/manifest.json @@ -0,0 +1,19 @@ +{ + "id": "gallery", + "name": "图库", + "version": "1.5.0", + "apiVersion": 1, + "main": "main.js", + "style": "styles.css", + "description": "右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供)", + "author": "official", + "icon": "🖼️", + "tags": [ + "资源", + "图库" + ], + "files": { + "main.js": "1b831a6bd2e3ab405a8524294cf422c04ff1bc950d0e2c012e1a686fec77926a", + "styles.css": "94c57b2d18deef3f672242efe1812ba1dc88dad90f03648d68feaa64bc70f572" + } +} diff --git a/plugins/gallery/styles.css b/plugins/gallery/styles.css new file mode 100644 index 0000000..1b997f9 --- /dev/null +++ b/plugins/gallery/styles.css @@ -0,0 +1,68 @@ +/* 图库插件样式(v1.5.0) + * 为什么放插件里:宿主 style.css 只在客户端发版时更新,而这里是「设置浮层/图标按钮/紧凑间距」这类 + * 高频视觉调整——随插件更新即可生效,不必重发桌面端。选择器均带 .iwb-gal-* / .iwb-history-* 前缀, + * 且比宿主同名规则更具体(.iwb-gal-foot .iwb-gal-icobtn),宿主旧样式不会盖回来。 + */ + +/* ---- 面板留白:边缘收小,避免窄栏里浪费空间 ---- */ +.iwb-history-embedded { padding: 8px 8px 6px; gap: 6px; } +.iwb-history-embedded .iwb-history-grid { gap: 6px; padding: 0 0 4px; } + +/* ---- 顶栏 ---- */ +.iwb-gal-head { display: flex; align-items: center; gap: 6px; min-height: 0; } +.iwb-gal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; } +.iwb-gal-actions .iwb-btn-sm { padding: 2px 7px; } + +/* ---- 底栏:左信息 / 右工具组 ---- */ +.iwb-gal-foot { + display: flex; align-items: center; justify-content: space-between; gap: 6px; + min-width: 0; padding-top: 6px; border-top: 1px solid var(--iwb-border); +} +.iwb-gal-foot-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 0 1 auto; overflow: hidden; } +.iwb-gal-count { font-size: 11px; color: var(--iwb-text2); white-space: nowrap; } +.iwb-gal-sel { font-size: 11px; color: var(--iwb-brand); white-space: nowrap; } +.iwb-gal-status { font-size: 11px; color: var(--iwb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; max-width: none; } +.iwb-gal-tools { display: flex; align-items: center; gap: 0; flex: 0 0 auto; margin-left: auto; } + +/* ---- 图标按钮:无外框、无底色,只在悬停时给一点反馈 ---- */ +.iwb-gal-foot .iwb-gal-icobtn, +.iwb-gal-foot .iwb-gal-icobtn:hover, +.iwb-gal-foot .iwb-gal-icobtn:active { + width: 20px; height: 20px; min-width: 20px; padding: 0; box-sizing: border-box; + display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; + border: 0; box-shadow: none; background: transparent; border-radius: 4px; + color: var(--iwb-text2); line-height: 1; transform: none; +} +.iwb-gal-foot .iwb-gal-icobtn svg { display: block; pointer-events: none; } +.iwb-gal-foot .iwb-gal-icobtn:hover { background: var(--iwb-layer2); color: var(--iwb-text); } +.iwb-gal-foot .iwb-gal-icobtn:focus-visible { outline: 2px solid color-mix(in srgb, var(--iwb-brand) 60%, transparent); outline-offset: 1px; } +.iwb-gal-setbtn-on { color: var(--iwb-brand); background: var(--iwb-layer2); } + +/* ---- 设置浮层(三个下拉不占前台) ---- */ +.iwb-gal-settings { + position: absolute; right: 8px; bottom: 34px; z-index: 30; width: 176px; max-width: calc(100% - 16px); + display: flex; flex-direction: column; gap: 8px; padding: 9px 10px; + background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 8px; + box-shadow: 0 6px 18px rgba(0, 0, 0, .14); +} +.iwb-gal-settings-title { font-size: 11px; font-weight: 600; color: var(--iwb-text2); } +.iwb-gal-setrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--iwb-text2); } +.iwb-gal-setlabel { flex: 0 0 auto; } +.iwb-gal-setrow select { flex: 1 1 auto; width: auto; min-width: 58px; max-width: 92px; height: 22px; font-size: 11px; padding: 0 2px 0 4px; } + +/* ---- 图片墙 ---- */ +.iwb-history-grid { overscroll-behavior: contain; } +.iwb-history-embedded .iwb-history-item { position: relative; flex: none; width: 100%; } +.iwb-history-embedded .iwb-history-item img { + width: 100%; height: auto; display: block; object-fit: contain; margin: 0 auto; + border-radius: 6px; border: 1px solid var(--iwb-border); background: var(--iwb-layer2); cursor: pointer; +} +.iwb-history-missing { + display: flex; align-items: center; justify-content: center; text-align: center; + min-height: 84px; padding: 8px; border-radius: 6px; border: 1px dashed var(--iwb-border); + font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer2); word-break: break-all; +} +.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 diff --git a/plugins/index.json b/plugins/index.json index 5d3e801..0727276 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -19,9 +19,14 @@ }, { "id": "gallery", - "file": "plugin-gallery.ec1dd4a6e21c.js", - "version": "1.4.2", - "integrity": "sha256-7B3UpuIcoi32fLiTjipMU/8Z4fjL+46PWWWM1ughTGk=" + "dir": "gallery", + "main": "main.js", + "style": "styles.css", + "version": "1.5.0", + "files": { + "main.js": "1b831a6bd2e3ab405a8524294cf422c04ff1bc950d0e2c012e1a686fec77926a", + "styles.css": "94c57b2d18deef3f672242efe1812ba1dc88dad90f03648d68feaa64bc70f572" + } }, { "id": "image-annotate", diff --git a/scripts/sync-plugins-from-repo.js b/scripts/sync-plugins-from-repo.js index 4bdf593..037e7be 100644 --- a/scripts/sync-plugins-from-repo.js +++ b/scripts/sync-plugins-from-repo.js @@ -14,7 +14,7 @@ const IDS = ['batch-export', 'blank-canvas', 'browser', 'gallery', 'image-annota // v3.25.41(M1):目录化插件试点 —— 这些 id 产出 /{manifest.json,main.js},其余仍是单文件(双轨兼容) // ⚠️ 2026-11-20 修正:桌面包不随包发插件(scripts/strip-plugins.js),插件只能从市场装, // 而市场目前只支持单文件 ⇒ 目录形态暂不用于生产插件,等 M3(zip 安装)落地再启用。 -const FOLDER_IDS = [] +const FOLDER_IDS = ['gallery'] const sha = (buf) => crypto.createHash('sha256').update(buf).digest() const shaHex = (buf) => sha(buf).toString('hex') @@ -39,17 +39,29 @@ for (const id of IDS) { const mainPath = path.join(dir, 'main.js') if (!fs.existsSync(mainPath) || shaHex(fs.readFileSync(mainPath)) !== shaHex(buf)) { fs.writeFileSync(mainPath, buf); copied++ } const meta = metaAll[id] || {} + // 可选 styles.css:插件自带样式(宿主 CSS 只在客户端发版时更新,视觉调整走插件更灵活) + const files = { 'main.js': shaHex(buf) } + let styleName = '' + const styleSrc = path.join(srcRoot, id, 'styles.css') + if (fs.existsSync(styleSrc)) { + const sbuf = fs.readFileSync(styleSrc) + const styleDest = path.join(dir, 'styles.css') + if (!fs.existsSync(styleDest) || shaHex(fs.readFileSync(styleDest)) !== shaHex(sbuf)) { fs.writeFileSync(styleDest, sbuf); copied++ } + styleName = 'styles.css' + files['styles.css'] = shaHex(sbuf) + } const manifestJson = { id: id, name: meta.name || id, version: pkg.version, apiVersion: Number((pkg.ibwPlugin && pkg.ibwPlugin.apiVersion) || 1), main: 'main.js', + ...(styleName ? { style: styleName } : {}), description: meta.desc || '', author: meta.author || 'official', icon: meta.icon || '', tags: Array.isArray(meta.tags) ? meta.tags : [], - files: { 'main.js': shaHex(buf) }, + files: files, } fs.writeFileSync(path.join(dir, 'manifest.json'), JSON.stringify(manifestJson, null, 2) + '\n') // 同 id 的旧单文件产物清理(目录优先,留着会造成两份) diff --git a/style.css b/style.css index b21a959..2fbd60a 100644 --- a/style.css +++ b/style.css @@ -2125,36 +2125,10 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-gal-count { font-size: 11px; color: var(--iwb-text2); white-space: nowrap; } .iwb-gal-status { font-size: 11px; color: var(--iwb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42%; } .iwb-gal-opts { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; margin-left: auto; } -/* 图库设置浮层(v1.4.0):三个下拉不再占前台,点「设置」从底栏上方浮出 */ +/* 图库视觉(浮层/图标按钮/紧凑间距)已迁到插件自带 gallery/styles.css(v1.5.0): + * 宿主 CSS 只在客户端发版时更新,插件样式随市场更新即生效,避免两处改、两处不一致。 + * 这里只留最小兜底:浮层需要相对定位容器。 */ .iwb-history-embedded { position: relative; } -/* 底栏右侧工具组(v1.4.2):刷新+设置并排靠右,互不挤压 */ -.iwb-gal-tools { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; margin-left: auto; } -.iwb-gal-setbtn { flex: 0 0 auto; } -/* 底栏图标按钮(v1.4.1/1.4.2):无外框、固定方形,窄栏不换行不重叠 */ -.iwb-gal-foot .iwb-gal-icobtn { - width: 22px; height: 22px; min-width: 22px; padding: 0; box-sizing: border-box; - display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; line-height: 1; - border: 0; background: transparent; border-radius: 5px; color: var(--iwb-text2); -} -.iwb-gal-icobtn svg { display: block; pointer-events: none; } -.iwb-gal-foot .iwb-gal-icobtn:hover { background: var(--iwb-layer2); border: 0; color: var(--iwb-text); } -.iwb-gal-foot .iwb-gal-icobtn:active { transform: none; } -.iwb-gal-foot .iwb-gal-icobtn:focus-visible { outline: 2px solid color-mix(in srgb, var(--iwb-brand) 60%, transparent); outline-offset: 1px; } -/* 左侧信息区不得溢出到工具组上 */ -.iwb-gal-foot { min-width: 0; } -.iwb-gal-foot-left { flex: 0 1 auto; min-width: 0; overflow: hidden; } -.iwb-gal-foot-left .iwb-gal-status { max-width: none; flex: 0 1 auto; } -.iwb-gal-setbtn-on { background: var(--iwb-layer2); border-color: var(--iwb-border-strong, var(--iwb-border)); } -.iwb-gal-settings { - position: absolute; right: 12px; bottom: 44px; z-index: 30; width: 186px; max-width: calc(100% - 24px); - display: flex; flex-direction: column; gap: 8px; padding: 10px; - background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 8px; - box-shadow: 0 6px 18px rgba(0, 0, 0, .14); -} -.iwb-gal-settings-title { font-size: 11px; font-weight: 600; color: var(--iwb-text2); } -.iwb-gal-setrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--iwb-text2); } -.iwb-gal-setlabel { flex: 0 0 auto; } -.iwb-gal-setrow select, .iwb-gal-settings select { flex: 1 1 auto; width: auto; min-width: 62px; max-width: 96px; height: 22px; font-size: 11px; padding: 0 2px 0 4px; } .iwb-gal-opt { display: inline-flex; align-items: center; gap: 3px; } /* 三个下拉尽量窄:只留内容 + 箭头的最小宽度(0.5K / 特大 / 全部 都放得下) */ .iwb-gal-opt select, .iwb-gal-opts select { width: auto; min-width: 34px; max-width: 44px; height: 20px; padding: 0 0 0 3px; font-size: 10px; }