fix(plugins): 读开关状态前先等待文件存储就绪 + 无记录不再强写启用;关闭状态跨重启保持
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 1m22s
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 1m22s
This commit is contained in:
1 parent
5dba56363a
commit
b7eb9f8c28
2 files changed
+10
-2
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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('')
|
||||
|
||||
Reference in new issue
Block a user