diff --git a/app.js b/app.js index d94c16c..e43cbc9 100644 --- a/app.js +++ b/app.js @@ -8557,6 +8557,15 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => const r = PluginHost && typeof PluginHost.setEnabled === 'function' ? PluginHost.setEnabled(id, true) : null return r && r.ok ? { ok: true } : { ok: false, error: (r && r.error) || '启用失败' } } + // 后台预热市场索引:设置页打开时直接命中缓存(网络慢也不影响首屏) + function wWarmMarketCache() { + try { + setTimeout(function () { + try { const p = wMarketList(); if (p && typeof p.catch === 'function') p.catch(function () { /* 离线也正常 */ }) } catch (e) { /* ignore */ } + }, 2500) + } catch (e) { /* ignore */ } + } + async function wLoadRuntimePlugins() { if (typeof fetch !== 'function' || typeof document === 'undefined') return // 内置清单(随包)先读;外部清单(<资料目录>/plugins/)只覆盖同 id 的条目 —— 合并而非替换 @@ -8630,9 +8639,11 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => 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) - else if (!want && PluginHost.isEnabled(r.id)) PluginHost.setEnabled(r.id, false) + // 注意:插件是在 init() 之后才注册的,init 的"激活已启用项"覆盖不到它们。 + // 所以这里对 want=true 一律再 setEnabled(true)(activate 幂等:已激活会返回 already), + // 否则会出现"开关显示已启用、实际没跑工厂函数"的假启用状态。 + if (want) PluginHost.setEnabled(r.id, true) + else if (typeof PluginHost.isEnabled === 'function' && PluginHost.isEnabled(r.id)) PluginHost.setEnabled(r.id, false) } } catch (e) { /* 状态应用失败不影响加载 */ } try { lsSet('iwb_plugin_load_status', JSON.stringify(wRuntimePlugins.map((r) => ({ id: r.id, status: r.status, source: r.source, error: r.error || '' })))) } catch (e2) { /* probe */ } @@ -8821,6 +8832,7 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => } } catch (e) { /* 预注册失败不影响启动 */ } wLoadRuntimePlugins() + wWarmMarketCache() } // 桌面端关闭图库定时清理(设置里已去掉该项):0 = 不限,避免老图被静默删掉 try {