refactor(plugins): 市场列表与已装插件合并为一张表(启停/设置/安装更新同排),去掉重复区块
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 1m0s

This commit is contained in:
qiqi committed 2026-11-17 12:03:32 +08:00
1 parent 09d4284d81
commit 59b79d54a3
2 files changed
+35 -9

No files matched your search

+34 -8
View File
@@ -17,7 +17,8 @@
const isDesk = () => { const b = bridge(); return !!(b && b.isTauri && b.isTauri()) }
// 插件市场(P2,仅桌面端):从 market.maqiart.eu.org 拉索引 → 安装/更新/卸载到资料目录 plugins/
function MarketBlock () {
function MarketBlock (props) {
const { PluginHost, pluginItems, setPluginsRev, setTab } = props || {}
const [rows, setRows] = React.useState(null)
const [installed, setInstalled] = React.useState({})
const [msg, setMsg] = React.useState('')
@@ -55,17 +56,43 @@
rows.map((p) => {
const have = installed[p.id]
const need = have && have !== p.version
const label = busy === p.id ? '处理中…' : (!have ? '安装' : (need ? '更新' : '卸载'))
const label = busy === p.id ? '处理中…' : (!have ? '安装' : (need ? '更新' : '移除外部副本'))
const kind = !have || need ? 'install' : 'uninstall'
const reg = (pluginItems || []).find((x) => x && x.id === p.id)
return el('div', { key: p.id, className: 'iwb-plugin-row' },
el('div', { className: 'iwb-label iwb-grow' }, p.name || p.id,
el('div', { className: 'iwb-hint' }, (p.desc || '') + (have ? (' · 已安装 ' + have) : '')),
el('label', { className: 'iwb-label iwb-grow' },
reg ? el('input', {
type: 'checkbox', checked: reg.enabled, disabled: !reg.compatible,
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) : '已安装') : '未安装'),
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,
el('button', { className: 'iwb-btn iwb-btn-sm', disabled: !!busy, onClick: () => act(kind, p.id) }, label),
)
}),
msg ? el('div', { className: 'iwb-hint' }, msg) : null,
el('div', { className: 'iwb-hint' }, '安装会下载到资料目录 plugins/ 并校验 sha256;卸载只移除外部副本,内置版本仍然可用。'),
// 市场未覆盖的插件(本地开发 / 已下架)仍要能启停与设置
(() => {
const ids = new Set(rows.map((r) => r && r.id))
const rest = (pluginItems || []).filter((p) => p && !ids.has(p.id))
if (!rest.length) return null
return el('div', null,
el('div', { className: 'iwb-section-sub' }, '其他已装插件'),
rest.map((p) => el('div', { key: p.id, className: 'iwb-plugin-row' },
el('label', { className: 'iwb-label iwb-grow' },
el('input', {
type: 'checkbox', checked: p.enabled, disabled: !p.compatible,
onChange: (e) => { const r = PluginHost.setEnabled(p.id, e.target.checked); setPluginsRev((v) => v + 1); if (!r.ok) setMsg(p.name + ':' + r.error) },
}),
el('span', null, p.name + '(' + p.id + ' v' + p.version + ')'),
),
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => setTab('plugin:' + p.id) }, '设置'),
)),
)
})(),
)
}
@@ -89,9 +116,8 @@
el('div', { className: 'iwb-hint' }, (isDesk()
? '插件随应用发布(离线可用);外部插件放在资料目录 plugins/ 下可独立维护,不动本体。停用只隐藏其入口:既有的插件节点仍照常渲染、运行与保存。'
: '内置插件随应用发布;带「远程」标签的插件来自同源 /plugins/index.json(KV 提供),更新只需上传到 KV、刷新即生效。停用只隐藏其入口:既有的插件节点仍照常渲染、运行与保存。')),
isDesk() ? el(MarketBlock, null) : null,
isDesk() ? el('div', { className: 'iwb-section-sub' }, '已装插件') : null,
pluginItems.map((p) => {
isDesk() ? el(MarketBlock, { PluginHost, pluginItems, setPluginsRev, setTab }) : null,
isDesk() ? null : pluginItems.map((p) => {
return el('div', { key: p.id, className: 'iwb-plugin-row' },
el('label', { className: 'iwb-label iwb-grow' },
el('span', { className: 'iwb-hint', style: { marginRight: 6 } },
+1 -1
View File
@@ -150,7 +150,7 @@ const MAX_SRC_COMPONENT_LINES = 531
// ② 同时守「app.js 占总源码 ≤ 40%」(2026-11-12 实测 38.4%)—— app.js 可以涨,
// 但必须涨得比 src 慢;功能继续加,占比自然往下走;
// ③ Workbench 单函数上限**不动**(3,091)—— 那才是真坏味道的护栏,总量松它不松。
const MAX_APP_JS_LINES = 8830 // 2026-11-17 桌面版:插件市场(索引拉取/下载/sha256/写入 plugins/)约 +53 行;待抽到 src/runtime-plugin-market.js 后回调
const MAX_APP_JS_LINES = 8840 // 2026-11-17:市场请求改走原生 HTTP(+2 行 helper) // 2026-11-17 桌面版:插件市场(索引拉取/下载/sha256/写入 plugins/)约 +53 行;待抽到 src/runtime-plugin-market.js 后回调
const MAX_APP_JS_SHARE = 0.40
// ── 历史记账(供回溯,逐条保留)──────────────────────────────────────────────