feat(market): 插件市场展示页(卡片墙 + 搜索 + 标签筛选),meta 补 icon/color/tags
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 1m55s

This commit is contained in:
qiqi committed 2026-11-17 15:55:55 +08:00
1 parent 67c6128d61
commit e2253e56c2
3 files changed
+172 -8

No files matched your search

+49 -7
View File
@@ -2,36 +2,78 @@
"batch-export": {
"name": "批量出图",
"desc": "资源中心勾选节点,串行批量生成并打包 ZIP 下载",
"author": "official"
"author": "official",
"icon": "🗂️",
"color": "#e8f0fe",
"tags": [
"出图",
"批处理"
]
},
"blank-canvas": {
"name": "空白画布",
"desc": "新建空白画布节点,用于分区分组",
"author": "official"
"author": "official",
"icon": "⬜",
"color": "#eef2f6",
"tags": [
"画布",
"效率"
]
},
"image-annotate": {
"name": "标注 / 修图",
"desc": "在画布内标注、涂抹、局部重绘",
"author": "official"
"author": "official",
"icon": "🖌️",
"color": "#fdeaea",
"tags": [
"修图",
"标注"
]
},
"image-vectorize": {
"name": "位图转矢量",
"desc": "把位图转成 SVG 矢量路径",
"author": "official"
"author": "official",
"icon": "✒️",
"color": "#eaf3ea",
"tags": [
"转换",
"矢量"
]
},
"style-source": {
"name": "风格库",
"desc": "风格提示词库与一键套用",
"author": "official"
"author": "official",
"icon": "🎨",
"color": "#fdf0e6",
"tags": [
"提示词",
"风格"
]
},
"white-bg-800": {
"name": "白底图",
"desc": "批量生成电商白底图(800px)",
"author": "official"
"author": "official",
"icon": "🧾",
"color": "#eef7fb",
"tags": [
"电商",
"出图"
]
},
"xianyi-cutout": {
"name": "鲜艺抠图",
"desc": "接入鲜艺抠图模型的一键去背景",
"author": "official"
"author": "official",
"icon": "✂️",
"color": "#f3eafd",
"tags": [
"抠图",
"去背景"
]
}
}
+122
View File
@@ -0,0 +1,122 @@
#!/usr/bin/env node
'use strict'
// 生成插件市场展示页:market/index.json → market.html(纯静态,无后端)
// 设计目标:与下载页同一套视觉;卡片墙 + 搜索 + 标签筛选;「安装」只在应用内做,这里只展示。
const fs = require('fs')
const path = require('path')
const root = path.resolve(__dirname, '..')
const index = JSON.parse(fs.readFileSync(path.join(root, 'market', 'index.json'), 'utf8'))
const list = Array.isArray(index.plugins) ? index.plugins : []
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]))
const tags = []
for (const p of list) for (const t of (p.tags || [])) if (tags.indexOf(t) < 0) tags.push(t)
const kb = (n) => n >= 1024 * 1024 ? (n / 1048576).toFixed(1) + ' MB' : Math.max(1, Math.round(n / 1024)) + ' KB'
const card = (p) => `
<article class="card" data-name="${esc((p.name + ' ' + p.id + ' ' + p.desc + ' ' + (p.tags || []).join(' ')).toLowerCase())}" data-tags="${esc((p.tags || []).join(','))}">
<div class="card-head">
<span class="avatar" style="background:${esc(p.color || '#eef2f6')}">${esc(p.icon || '◻')}</span>
<div class="card-title">
<h3>${esc(p.name)}</h3>
<div class="sub">${esc(p.author === 'official' ? '官方' : p.author)} · v${esc(p.version)} · ${kb(p.size || 0)}</div>
</div>
</div>
<p class="desc">${esc(p.desc)}</p>
<div class="tags">${(p.tags || []).map((t) => `<span class="tag">${esc(t)}</span>`).join('')}</div>
</article>`
const html = `<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>插件市场 · Image Workbench</title>
<style>
:root { --fg:#1a1a1a; --fg2:#6b6b6b; --line:#ececec; --bg:#fff; --chip:#f4f4f4; }
@media (prefers-color-scheme: dark) {
:root { --fg:#f2f2f2; --fg2:#9a9a9a; --line:#2a2a2a; --bg:#111; --chip:#1d1d1d; }
}
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font:15px/1.65 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif; }
.wrap { max-width:1080px; margin:0 auto; padding:56px 24px 80px; }
header h1 { font-size:28px; margin:0 0 6px; letter-spacing:-.02em; }
header p { margin:0; color:var(--fg2); font-size:14px; }
.toolbar { display:flex; gap:12px; margin:28px 0 18px; flex-wrap:wrap; align-items:center; }
input[type=search] { flex:1 1 260px; min-width:220px; padding:10px 14px; border:1px solid var(--line); border-radius:10px; background:var(--bg); color:var(--fg); font-size:14px; outline:none; }
input[type=search]:focus { border-color:#111; }
.chips { display:flex; gap:8px; flex-wrap:wrap; }
.chip { padding:6px 12px; border:1px solid var(--line); border-radius:999px; background:transparent; color:var(--fg2); font-size:13px; cursor:pointer; }
.chip.on { background:#111; color:#fff; border-color:#111; }
@media (prefers-color-scheme: dark) { .chip.on { background:#f2f2f2; color:#111; border-color:#f2f2f2; } }
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:16px; }
.card { border:1px solid var(--line); border-radius:14px; padding:18px; display:flex; flex-direction:column; gap:12px; }
.card-head { display:flex; gap:12px; align-items:center; }
.avatar { width:44px; height:44px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:22px; flex:0 0 44px; }
.card-title h3 { margin:0; font-size:16px; font-weight:600; }
.card-title .sub { color:var(--fg2); font-size:12.5px; margin-top:2px; }
.desc { margin:0; color:var(--fg2); font-size:13.5px; min-height:42px; }
.tags { display:flex; gap:6px; flex-wrap:wrap; margin-top:auto; }
.tag { padding:2px 9px; border-radius:999px; background:var(--chip); color:var(--fg2); font-size:12px; }
.empty { color:var(--fg2); padding:40px 0; text-align:center; }
footer { margin-top:40px; color:var(--fg2); font-size:13px; border-top:1px solid var(--line); padding-top:18px; }
code { background:var(--chip); padding:1px 6px; border-radius:6px; font-size:12.5px; }
</style>
</head>
<body>
<div class="wrap">
<header>
<h1>插件市场</h1>
<p>Image Workbench 插件 · 共 <b>${list.length}</b> 个 · 在应用内「设置 → 插件」安装</p>
</header>
<div class="toolbar">
<input id="q" type="search" placeholder="搜索插件,例如:出图、抠图、矢量…" autocomplete="off">
<div class="chips" id="chips">
<button class="chip on" data-tag="">全部</button>
${tags.map((t) => `<button class="chip" data-tag="${esc(t)}">${esc(t)}</button>`).join('')}
</div>
</div>
<div class="grid" id="grid">${list.map(card).join('')}</div>
<div class="empty" id="empty" hidden>没有匹配的插件</div>
<footer>
安装方式:应用内 <code>设置 → 插件 → 可安装(市场)</code> 点「安装」,重启后生效。<br>
插件目录:<code>~/Documents/ImageWorkbench/plugins/</code>(Windows:<code>%USERPROFILE%\\Documents\\ImageWorkbench\\plugins\\</code>)
</footer>
</div>
<script>
var q = document.getElementById('q')
var grid = document.getElementById('grid')
var empty = document.getElementById('empty')
var chips = document.getElementById('chips')
var activeTag = ''
function apply () {
var kw = (q.value || '').trim().toLowerCase()
var shown = 0
Array.prototype.forEach.call(grid.children, function (el) {
var okKw = !kw || el.dataset.name.indexOf(kw) >= 0
var okTag = !activeTag || (',' + el.dataset.tags + ',').indexOf(',' + activeTag + ',') >= 0
var ok = okKw && okTag
el.hidden = !ok
if (ok) shown++
})
empty.hidden = shown > 0
}
q.addEventListener('input', apply)
chips.addEventListener('click', function (e) {
var b = e.target.closest('.chip')
if (!b) return
Array.prototype.forEach.call(chips.children, function (x) { x.classList.remove('on') })
b.classList.add('on')
activeTag = b.dataset.tag || ''
apply()
})
</script>
</body>
</html>
`
fs.writeFileSync(path.join(root, 'market', 'index.html'), html)
console.log('market/index.html 已生成(' + list.length + ' 个插件 / ' + tags.length + ' 个标签)')
+1 -1
View File
@@ -19,7 +19,7 @@ for (const e of man) {
fs.writeFileSync(path.join(out, 'plugins', e.file), buf)
const m = meta[e.id] || {}
plugins.push({
id: e.id, name: m.name || e.id, desc: m.desc || '', author: m.author || 'official',
id: e.id, name: m.name || e.id, desc: m.desc || '', author: m.author || 'official', icon: m.icon || '', color: m.color || '', tags: Array.isArray(m.tags) ? m.tags : [],
version: e.version, apiVersion: 1,
file: 'plugins/' + e.file,
size: buf.length,