#!/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) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[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) => `
${esc(p.icon || '◻')}

${esc(p.name)}

${esc(p.author === 'official' ? '官方' : p.author)} · v${esc(p.version)} · ${kb(p.size || 0)}

${esc(p.desc)}

${(p.tags || []).map((t) => `${esc(t)}`).join('')}
` const html = ` 插件市场 · Image Workbench

插件市场

Image Workbench 插件 · 共 ${list.length} 个 · 在应用内「设置 → 插件」安装

${tags.map((t) => ``).join('')}
${list.map(card).join('')}
` fs.writeFileSync(path.join(root, 'market', 'index.html'), html) console.log('market/index.html 已生成(' + list.length + ' 个插件 / ' + tags.length + ' 个标签)')