feat(settings): 通用页加「版本与更新」+ 在线更新方案文档(A/B/C 三方案与配置清单)
Verify Web / e2e (Playwright) (push) Skipped
Verify Web / gate (build · lint · unit · facts) (push) Canceled after 0s

This commit is contained in:
qiqi committed 2026-11-17 09:17:05 +08:00
1 parent b3a30c7ad7
commit d0c3edf352
3 files changed
+125 -1

No files matched your search

+42 -1
View File
@@ -74,6 +74,45 @@
return pluginsTab
}
// 版本与更新(独立组件:自己持有提示状态,不污染 generalTab 的 hook 顺序)
function VersionBlock (props) {
const version = props && props.version ? String(props.version) : ''
const [msg, setMsg] = React.useState('')
const check = async () => {
try {
const U = (typeof window !== 'undefined' && window.__TAURI__ && window.__TAURI__.updater) ? window.__TAURI__.updater : null
if (!U || typeof U.check !== 'function') {
setMsg('在线更新尚未启用:需要配置更新源地址与签名公钥(见 docs/DESKTOP_UPDATE.md)')
return
}
setMsg('正在检查…')
const u = await U.check()
if (!u) { setMsg('已是最新版本'); return }
setMsg('发现新版本 ' + (u.version || '') + ',点「立即更新」下载安装')
window.__IWB_UPDATE__ = u
} catch (e) { setMsg('检查失败:' + String((e && e.message) || e)) }
}
const install = async () => {
try {
const u = window.__IWB_UPDATE__
if (!u || typeof u.downloadAndInstall !== 'function') { setMsg('没有可安装的更新'); return }
setMsg('正在下载安装…')
await u.downloadAndInstall()
setMsg('安装完成,请重启应用')
} catch (e) { setMsg('更新失败:' + String((e && e.message) || e)) }
}
return el('div', null,
el('div', { className: 'iwb-section-sub' }, '版本与更新'),
el('div', { className: 'iwb-row' },
el('span', { className: 'iwb-label' }, '版本'),
el('span', { className: 'iwb-hint', style: { flex: '1 1 auto' } }, version || '未知'),
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: check }, '检查更新'),
window.__IWB_UPDATE__ ? el('button', { className: 'iwb-btn iwb-btn-sm', onClick: install }, '立即更新') : null,
),
el('div', { className: 'iwb-hint' }, '当前为本地目录版;在线更新需要「更新源 + 签名密钥」两样东西配好才会生效。'),
msg ? el('div', { className: 'iwb-hint' }, msg) : null,
)
}
// 桌面端专属:默认下载文件夹。独立组件持有 useState ⇒ 不干扰 generalTab 的 hook 顺序。
function DownloadDirBlock () {
const D = (typeof window !== 'undefined') ? window.IWBDesktop : null
@@ -169,7 +208,7 @@
}
function renderGeneralTab (ctx) {
const { TASK_STALL_END_MAX, TASK_STALL_END_MIN, applyTheme, draft, imageLibSection, setDraft, setTheme, theme } = ctx
const { TASK_STALL_END_MAX, TASK_STALL_END_MIN, appVersion, applyTheme, draft, imageLibSection, setDraft, setTheme, theme } = ctx
const generalTab = el('div', { className: 'iwb-section' },
el('div', { className: 'iwb-section-title' }, '数据与目录'),
// 桌面端才有目录概念;网页版退回原来的浏览器说明
@@ -194,6 +233,8 @@
el('div', { style: { height: 16 } }),
// 原「图片保存」页并入这里(定时清理已去掉)
imageLibSection || null,
el('div', { style: { height: 16 } }),
el(VersionBlock, { version: appVersion }),
// 桌面端没有服务端、也没有「浏览器本地模式」这回事 ⇒ 整段不渲染
isDesk() ? null : el('div', { className: 'iwb-section-sub' }, '访问口令'),
isDesk() ? null : el('div', { className: 'iwb-hint' }, '口令是服务端(Node 版 image-workbench-app)的 Basic Auth 功能;当前为浏览器本地模式(数据存在你的浏览器),页面与数据本就只在本机,无需设置口令。'),