Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m22s
现象:mac 先发 3.26.108、win 还在构建时,下载页 Windows 行从「3.26.107 下载」变成「暂未提供」—— 等于把仍在用的旧版下载入口也关掉了。 原因:gen-release-page 只读 data.releases[0](最新版本)的 platforms,那一版缺少某平台就没有条目。 改动:新增 newestFor(key),逐平台回溯到最近一个真正提供该包的版本,行内版本号用该条目自己的版本; 三平台同批发布时行为不变。
170 lines
9.0 KiB
JavaScript
170 lines
9.0 KiB
JavaScript
#!/usr/bin/env node
|
||
'use strict'
|
||
// 下载页生成器:site/releases.json → site/index.html
|
||
// 只做纯静态输出(无外链、无框架),部署到 NAS 的 nginx 静态目录。
|
||
const fs = require('fs')
|
||
const path = require('path')
|
||
|
||
const root = path.resolve(__dirname, '..')
|
||
const inFile = process.argv[2] || path.join(root, 'site', 'releases.json')
|
||
const outFile = process.argv[3] || path.join(root, 'site', 'download', 'index.html')
|
||
const data = JSON.parse(fs.readFileSync(inFile, 'utf8'))
|
||
|
||
const PLATFORMS = [
|
||
{ key: 'darwin-aarch64', label: 'macOS · Apple Silicon', hint: 'M1 / M2 / M3 / M4' },
|
||
{ key: 'darwin-x86_64', label: 'macOS · Intel', hint: 'x86_64' },
|
||
{ key: 'windows-x86_64', label: 'Windows · x64', hint: '需要 WebView2' },
|
||
]
|
||
|
||
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]))
|
||
const fmtSize = (n) => (!n ? '' : (n / 1048576).toFixed(1) + ' MB')
|
||
|
||
// v3.26.108:按平台取「最近一个真正提供该包的版本」。
|
||
// 以前只读 data.releases[0]:三平台不同批发布时(如 mac 已发、win 还在构建),
|
||
// 另一个平台会显示「暂未提供」,等于把旧版下载入口也关掉了。
|
||
function newestFor (key) {
|
||
for (const r of (data.releases || [])) {
|
||
const it = r.platforms && r.platforms[key]
|
||
if (it) return { rel: r, item: it }
|
||
}
|
||
return null
|
||
}
|
||
function platformRow (rel, p, itemOverride) {
|
||
const item = itemOverride || (rel && rel.platforms ? rel.platforms[p.key] : null)
|
||
const meta = item
|
||
? '版本 ' + esc((itemOverride && itemOverride.__rel ? itemOverride.__rel.version : rel.version)) + ' · ' + fmtSize(item.size) + ' · .' + esc(item.kind || 'dmg')
|
||
: ''
|
||
const action = item
|
||
? '<a class="btn" href="/' + esc(item.file) + (item.h ? '?h=' + esc(item.h) : '') + '">下载</a>'
|
||
: '<span class="muted">暂未提供</span>'
|
||
const hash = item && item.sha256
|
||
? '<div class="hash">sha256 ' + esc(item.sha256.slice(0, 16)) + '…</div>'
|
||
: ''
|
||
return ' <div class="row">\n' +
|
||
' <div class="name">' + esc(p.label) + '<div class="hint">' + esc(p.hint) + '</div></div>\n' +
|
||
' <div class="meta">' + meta + hash + '</div>\n' +
|
||
' ' + action + '\n' +
|
||
' </div>'
|
||
}
|
||
|
||
const latest = data.releases && data.releases[0]
|
||
const history = (data.releases || []).map((r) => {
|
||
const avail = Object.keys(r.platforms || {}).map((k) => {
|
||
const p = PLATFORMS.find((x) => x.key === k)
|
||
return p ? p.label : k
|
||
})
|
||
return ' <div class="row">\n' +
|
||
' <div class="name">' + esc(r.version) + (r.notes ? '<div class="hint">' + esc(r.notes) + '</div>' : '') + '</div>\n' +
|
||
' <div class="meta">' + esc(r.date || '') + '<div class="hint">' + esc(avail.join(' / ') || '—') + '</div></div>\n' +
|
||
' </div>'
|
||
}).join('\n')
|
||
|
||
const html = `<!doctype html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
<title>${esc(data.app)} · 下载</title>
|
||
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
||
<link rel="apple-touch-icon" href="/assets/logo.png">
|
||
<link rel="stylesheet" href="/assets/style.css?v=" + encodeURIComponent(latest.version + '-' + Date.now().toString(36)) + "">
|
||
<style>
|
||
*{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}
|
||
.dlwrap{max-width:760px;margin:0 auto;padding:48px 0 64px}
|
||
h1{font-size:27px;margin:0 0 6px;letter-spacing:-.01em}
|
||
.sub{color:var(--muted);margin:0 0 34px}
|
||
h2{font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;margin:38px 0 2px}
|
||
.row{display:flex;align-items:center;gap:16px;padding:15px 0;border-bottom:1px solid var(--line)}
|
||
.row:first-of-type{border-top:1px solid var(--line)}
|
||
.name{flex:1 1 auto;font-weight:550}
|
||
.hint{color:var(--muted);font-size:12.5px;font-weight:400;margin-top:2px}
|
||
.meta{flex:0 0 auto;text-align:right;color:var(--muted);font-size:13px}
|
||
.hash{font-size:11.5px;opacity:.75;margin-top:2px;font-variant-numeric:tabular-nums}
|
||
.btn{flex:0 0 auto;font-size:13px;padding:7px 18px;border-radius:8px;background:var(--brand);color:var(--bg);text-decoration:none}
|
||
.btn:hover{opacity:.88}
|
||
.muted{flex:0 0 auto;font-size:13px;color:var(--muted);opacity:.7}
|
||
.foot{margin-top:46px;color:var(--muted);font-size:12.5px;line-height:1.8}
|
||
.foot a{color:inherit}
|
||
code{font-size:12.5px}
|
||
.steps{margin:6px 0 0;padding-left:22px;color:var(--fg2);font-size:13.5px;line-height:1.9}
|
||
.steps li{margin:2px 0}
|
||
.steps b{color:var(--fg);font-weight:600}
|
||
pre.cmd{margin:10px 0 0;padding:10px 12px;background:var(--bg2);border:1px solid var(--line);border-radius:8px;overflow-x:auto}
|
||
pre.cmd code{font-size:12px;color:var(--fg)}
|
||
.note{margin:10px 0 0;color:var(--muted);font-size:12.5px;line-height:1.8}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<nav><div class="wrap inner">
|
||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||
<div class="links">
|
||
<a href="/">首页</a>
|
||
<a href="/download/" class="on">下载</a>
|
||
<a href="/plugins/">插件</a>
|
||
<a href="/dev/">开发</a>
|
||
<a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码</a>
|
||
</div>
|
||
<div class="right">
|
||
<a class="btn" href="/plugins/">插件市场</a>
|
||
<a class="btn primary" href="/download/">下载</a>
|
||
</div>
|
||
</div></nav>
|
||
|
||
<div class="wrap"><div class="dlwrap">
|
||
<h1>${esc(data.app)}</h1>
|
||
<p class="sub">${esc(data.subtitle || '')}</p>
|
||
|
||
<h2>下载</h2>
|
||
${PLATFORMS.map((p) => { const hit = newestFor(p.key); const it = hit ? Object.assign({}, hit.item, { __rel: hit.rel }) : null; return platformRow(hit ? hit.rel : latest, p, it) }).join('\n')}
|
||
|
||
<h2>系统要求</h2>
|
||
<div class="row">
|
||
<div class="name">macOS 12 及以上 / Windows 10 1803 及以上(含 WebView2)
|
||
<div class="hint">数据全部保存在本地目录 <code>~/Documents/ImageWorkbench</code>,可整目录备份与迁移。</div>
|
||
</div>
|
||
</div>
|
||
|
||
<h2>安装步骤(macOS)</h2>
|
||
<ol class="steps">
|
||
<li>下载上面的 <b>.dmg</b>(Apple 芯片选 Apple Silicon;老 Intel 机器选 Intel)。</li>
|
||
<li>双击打开 dmg,把 <b>Image Workbench</b> 图标拖进「应用程序」文件夹。</li>
|
||
<li>第一次启动:打开「应用程序」,<b>右键点图标 → 打开</b>,弹窗里再点一次「打开」。</li>
|
||
<li>如果提示「已损坏」或「无法验证开发者」:打开「终端」,粘贴执行下面这条命令,然后重新打开应用。</li>
|
||
</ol>
|
||
<pre class="cmd"><code>xattr -dr com.apple.quarantine "/Applications/image-workbench.app"</code></pre>
|
||
<p class="note">说明:安装包未做 Apple 公证($99/年开发者账号),所以第一次需要手动放行;这一步只做一次。<br>
|
||
之后有新版本时,应用内 <b>设置 → 通用 → 版本与更新 → 检查更新</b> 就能一键升级,不用再下载安装包。</p>
|
||
|
||
<h2>安装步骤(Windows)</h2>
|
||
<ol class="steps">
|
||
<li>下载 <b>.exe</b>(NSIS 安装包,按当前用户安装,不需要管理员权限)。</li>
|
||
<li>双击运行;若出现「Windows 已保护你的电脑」,点「更多信息 → 仍要运行」。</li>
|
||
<li>安装完成后从开始菜单启动;数据在 <code>%USERPROFILE%\Documents\ImageWorkbench</code>。</li>
|
||
</ol>
|
||
|
||
<h2>历史版本</h2>
|
||
${history}
|
||
|
||
<div class="foot">
|
||
本页由 <code>scripts/gen-release-page.js</code> 从 releases.json 生成 · 源码 <a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop">git.maqiart.eu.org</a> · 更新于 ${esc((data.updatedAt || '').slice(0, 10))}
|
||
</div>
|
||
</div></div>
|
||
|
||
<footer><div class="wrap">
|
||
<div class="cols">
|
||
<div><div style="color:#fff;font-weight:640;margin-bottom:8px">Image Workbench</div>
|
||
<div style="font-size:13px;line-height:1.8">本地优先的 AI 生图无限画布。图片、提示词与模型配置全部留在你自己的电脑里。</div></div>
|
||
<div><h4>产品</h4><a href="/">首页</a><a href="/download/">下载</a><a href="/plugins/">插件市场</a></div>
|
||
<div><h4>资源</h4><a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop" target="_blank" rel="noopener">源码仓库</a><a href="https://git.maqiart.eu.org/malongan/iwb-plugins-desktop" target="_blank" rel="noopener">插件仓库</a><a href="/updates/latest.json" target="_blank" rel="noopener">更新源</a></div>
|
||
<div><h4>说明</h4><a href="/download/">安装步骤</a><a href="/plugins/">插件安装</a></div>
|
||
</div>
|
||
<div class="copy"><span>© Image Workbench</span><span>数据保存在本地 · 不上传任何图片</span></div>
|
||
</div></footer>
|
||
</body>
|
||
</html>
|
||
`
|
||
fs.mkdirSync(path.dirname(outFile), { recursive: true })
|
||
fs.writeFileSync(outFile, html)
|
||
console.log('已生成 ' + path.relative(root, outFile) + '(' + data.releases.length + ' 个版本 / ' + Object.keys((latest && latest.platforms) || {}).length + ' 个平台)')
|