From b7eb9f8c2831777ea197bd3910720e6fd1d4e50f Mon Sep 17 00:00:00 2001 From: qiqi Date: Tue, 17 Nov 2026 16:51:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugins):=20=E8=AF=BB=E5=BC=80=E5=85=B3?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=89=8D=E5=85=88=E7=AD=89=E5=BE=85=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AD=98=E5=82=A8=E5=B0=B1=E7=BB=AA=20+=20=E6=97=A0?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E4=B8=8D=E5=86=8D=E5=BC=BA=E5=86=99=E5=90=AF?= =?UTF-8?q?=E7=94=A8=EF=BC=9B=E5=85=B3=E9=97=AD=E7=8A=B6=E6=80=81=E8=B7=A8?= =?UTF-8?q?=E9=87=8D=E5=90=AF=E4=BF=9D=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 11 +++++++++-- src/ui-settings-sections.js | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index b403822..393c726 100644 --- a/app.js +++ b/app.js @@ -8580,7 +8580,13 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => } catch (e) { /* 开发者模式读取失败不影响启动 */ } for (const e of ext) { const id = String((e && e.id) || ''); if (id) byId.set(id, Object.assign({}, e, { source: 'external' })) } // 关键:加载前先快照「用户关掉过哪些插件」,加载过程绝不能覆盖这个状态 - const persistedState = (function () { try { const v = lsGet('iwb_plugins', {}); return (v && typeof v === 'object') ? v : {} } catch (e) { return {} } })() + let persistedState = {} + try { + const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null + if (F && typeof F.ready === 'function') { try { await F.ready({ wizard: false }) } catch (e) { /* 已就绪 */ } } + const v = lsGet('iwb_plugins', {}) + persistedState = (v && typeof v === 'object') ? v : {} + } catch (e) { persistedState = {} } const manifest = Array.from(byId.values()) if (!manifest.length) return const list = Array.isArray(manifest) ? manifest : (manifest && Array.isArray(manifest.plugins) ? manifest.plugins : []) @@ -8614,7 +8620,8 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => for (const r of (wRuntimePlugins || [])) { if (!r || r.status !== 'loaded') continue const rec = st[r.id] - const want = !(rec && rec.enabled === false) + if (!rec) continue + const want = rec.enabled !== false if (!PluginHost || typeof PluginHost.setEnabled !== 'function') continue if (typeof PluginHost.isEnabled !== 'function') continue if (want && !PluginHost.isEnabled(r.id)) PluginHost.setEnabled(r.id, true) diff --git a/src/ui-settings-sections.js b/src/ui-settings-sections.js index 15b6176..a0355eb 100644 --- a/src/ui-settings-sections.js +++ b/src/ui-settings-sections.js @@ -183,6 +183,7 @@ } const r = PluginHost.setEnabled(id, on) if (!r.ok) setMsg('切换失败:' + r.error) + else setMsg(on ? '已启用' : '已停用(重启后保持关闭)') } finally { setPluginsRev(function (v) { return v + 1 }) setBusy('')