fix(settings): 插件全部误报「可更新」(对象比字符串)v3.25.48

- 3.25.47 把已安装映射改为 {version,dir,file},但 newer 仍用 m.version !== inst[id] ⇒ 恒 true
- 改比 inst[id].version,并统一用 compareVersions(a,b) > 0(市场回退也不误报)
- 加源文本回归钉点:禁止 m.version !== inst[id]
This commit is contained in:
qiqi committed 2026-11-20 10:39:24 +08:00
1 parent fb8d13bf5c
commit a21a73b370
7 files changed
+25 -7

No files matched your search

+9 -3
View File
@@ -205,7 +205,7 @@
return {
id: id,
name: m.name || (reg && reg.name) || id,
version: m.version || inst[id] || (reg && reg.version) || '',
version: m.version || (inst[id] && inst[id].version) || (reg && reg.version) || '',
desc: m.desc || '',
author: m.author || '',
icon: m.icon || '◻',
@@ -214,16 +214,22 @@
enabled: reg ? !!reg.enabled : true,
compatible: reg ? !!reg.compatible : true,
registered: !!reg,
newer: !!(m.version && inst[id] && m.version !== inst[id]),
newer: !!(m.version && inst[id] && inst[id].version && cmpV(m.version, inst[id].version) > 0),
}
}).filter(function (row) { return hit(row.name, row.desc) })
const availRows = mList.filter(function (m) { return !(m.id in inst) && !regById[m.id] && hit(m.name, m.desc) })
const updatable = Object.keys(inst).filter(function (id) { const m = findM(id); return m.version && m.version !== inst[id] }).length
const updatable = Object.keys(inst).filter(function (id) { const m = findM(id); const iv = inst[id] && inst[id].version; return !!(m.version && iv && cmpV(m.version, iv) > 0) }).length
const dirHint = (function () {
const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null
return (F && F.dir && F.dir()) ? (F.dir() + '/plugins/') : '资料目录/plugins/'
})()
const kb = function (n) { return !n ? '' : (n >= 1048576 ? (n / 1048576).toFixed(1) + ' MB' : Math.max(1, Math.round(n / 1024)) + ' KB') }
// 版本比较统一走 loader.compareVersions(>0 才算有更新;避免「对象 vs 字符串」误判、也避免市场回退版本时误报)
const cmpV = function (a, b) {
const L = (typeof window !== 'undefined') ? window.IWBRuntimePluginLoader : null
if (L && typeof L.compareVersions === 'function') return L.compareVersions(a, b)
return String(a) === String(b) ? 0 : 1
}
// ── 管理页:横向列表(名称/版本/作者 + 描述 + 操作 + 开关),像 Obsidian「第三方插件」 ──
const manageView = function () {