feat(market-ui): 已安装同版本也能「转为新格式」重装(单文件→目录)v3.25.47
- 管理页行内动作拆成 安装/更新/转为新格式/重新安装 + 独立「移除」 - 市场卡片页给已安装插件补「重装」 - 已安装状态区分「旧格式」(index 条目只有 file、没有 dir)
This commit is contained in:
1 parent
e4bd818e15
commit
94820d4d7f
6 files changed
+23
-16
No files matched your search
+11
-12
@@ -32,7 +32,7 @@
|
||||
const list = await D.market.list()
|
||||
const cur = await D.market.installed()
|
||||
const map = {}
|
||||
for (const p of (cur || [])) if (p && p.id) map[p.id] = p.version || ''
|
||||
for (const p of (cur || [])) if (p && p.id) map[p.id] = { version: p.version || '', dir: p.dir || '', file: p.file || '' }
|
||||
setRows(list); setInstalled(map); setMsg('')
|
||||
} catch (e) { setRows([]); setMsg('市场加载失败:' + String((e && e.message) || e)) }
|
||||
}, [D])
|
||||
@@ -56,13 +56,12 @@
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: refresh }, '刷新'),
|
||||
),
|
||||
rows.map((p) => {
|
||||
const have = installed[p.id]
|
||||
const need = have && have !== p.version
|
||||
const label = busy === p.id ? '处理中…' : (!have ? '安装' : (need ? '更新' : '移除外部副本'))
|
||||
const kind = !have || need ? 'install' : 'uninstall'
|
||||
const entry = installed[p.id] || null
|
||||
const have = entry ? entry.version : ''
|
||||
const need = !!have && have !== p.version
|
||||
const legacy = !!(entry && !entry.dir) // 旧的单文件安装(M3 前):可一键转成新目录格式
|
||||
const label = busy === p.id ? '处理中…' : (!entry ? '安装' : (need ? '更新' : (legacy ? '转为新格式' : '重新安装')))
|
||||
const reg = (pluginItems || []).find((x) => x && x.id === p.id)
|
||||
// 内置已提供同版本 ⇒ 无需再装外部副本(避免「安装」一个本来就有的插件)
|
||||
const builtinSame = !have && reg && reg.version === p.version
|
||||
return el('div', { key: p.id, className: 'iwb-plugin-row' },
|
||||
el('label', { className: 'iwb-label iwb-grow' },
|
||||
reg ? el('input', {
|
||||
@@ -70,13 +69,12 @@
|
||||
onChange: (e) => { const r = PluginHost.setEnabled(reg.id, e.target.checked); setPluginsRev((v) => v + 1); if (!r.ok) setMsg(reg.name + ':' + r.error) },
|
||||
}) : null,
|
||||
el('span', null, (p.name || p.id) + ' v' + p.version),
|
||||
el('span', { className: 'iwb-hint', style: { marginLeft: 8 } }, have ? (need ? ('已装 ' + have) : '已安装') : '未安装'),
|
||||
el('span', { className: 'iwb-hint', style: { marginLeft: 8 } }, entry ? (need ? ('已装 ' + have) : (legacy ? '已安装(旧格式)' : '已安装')) : '未安装'),
|
||||
p.desc ? el('div', { className: 'iwb-hint' }, p.desc) : null,
|
||||
),
|
||||
reg ? el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => setTab('plugin:' + p.id) }, '设置') : null,
|
||||
builtinSame
|
||||
? el('span', { className: 'iwb-hint' }, '内置已提供')
|
||||
: el('button', { className: 'iwb-btn iwb-btn-sm', disabled: !!busy, onClick: () => act(kind, p.id) }, label),
|
||||
el('button', { className: 'iwb-btn iwb-btn-sm', disabled: !!busy, onClick: () => act('install', p.id) }, label),
|
||||
entry ? el('button', { className: 'iwb-btn iwb-btn-sm iwb-btn-danger', disabled: !!busy, onClick: () => act('uninstall', p.id) }, '移除') : null,
|
||||
)
|
||||
}),
|
||||
msg ? el('div', { className: 'iwb-hint' }, msg) : null,
|
||||
@@ -145,7 +143,7 @@
|
||||
try {
|
||||
const cur = await D.market.installed()
|
||||
const map = {}
|
||||
for (const p of (cur || [])) if (p && p.id) map[p.id] = p.version || ''
|
||||
for (const p of (cur || [])) if (p && p.id) map[p.id] = { version: p.version || '', dir: p.dir || '', file: p.file || '' }
|
||||
setInst(map)
|
||||
} catch (e) { /* 本地清单失败不阻塞市场请求 */ }
|
||||
try {
|
||||
@@ -400,6 +398,7 @@
|
||||
el('div', { className: 'iwb-mk-sub' }, bits.join(' · ')),
|
||||
),
|
||||
el('div', { className: 'iwb-mk-actions' },
|
||||
((m.id in inst) || regById[m.id]) ? el('button', { className: 'iwb-btn iwb-btn-sm', disabled: !!busy, onClick: function () { act('install', m.id) } }, busy === m.id ? '处理中…' : '重装') : null,
|
||||
((m.id in inst) || regById[m.id])
|
||||
? el('button', { className: 'iwb-btn iwb-btn-sm', disabled: !!busy, onClick: function () { act('uninstall', m.id) } }, '移除')
|
||||
: el('button', { className: 'iwb-btn iwb-btn-sm iwb-btn-primary', disabled: !!busy, onClick: function () { act('install', m.id) } }, busy === m.id ? '处理中…' : '安装'),
|
||||
|
||||
Reference in new issue
Block a user