feat(plugins): 管理页显示加载错误原因 + 「复制诊断」(清单/运行时状态/错误)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m13s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m13s
This commit is contained in:
1 parent
9fa45ff7b0
commit
5aeb354043
1 file changed
+27
@@ -231,6 +231,32 @@
|
||||
el('span', { className: 'iwb-switch-track' }, el('span', { className: 'iwb-switch-dot' })),
|
||||
),
|
||||
),
|
||||
el('div', { className: 'iwb-mk-setrow' },
|
||||
el('div', { className: 'iwb-mk-setrow-main' },
|
||||
el('div', { className: 'iwb-mk-setrow-title' }, '插件诊断'),
|
||||
el('div', { className: 'iwb-hint' }, '加载失败时点这里复制诊断 JSON(含清单、运行时状态、错误原因)'),
|
||||
),
|
||||
el('button', {
|
||||
className: 'iwb-btn iwb-btn-sm',
|
||||
onClick: async function () {
|
||||
try {
|
||||
const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null
|
||||
let manifest = []
|
||||
try { manifest = await F.plugins.manifest() } catch (e) { manifest = String(e && e.message) }
|
||||
const payload = {
|
||||
dir: (F && F.dir) ? F.dir() : '',
|
||||
devMode: pluginDevGet(),
|
||||
manifest: manifest,
|
||||
runtime: (wRuntimePlugins || []).map(function (r) { return { id: r.id, status: r.status, source: r.source, error: r.error || '', file: r.file, version: r.version } }),
|
||||
registered: (pluginItems || []).map(function (p) { return { id: p.id, enabled: p.enabled, compatible: p.compatible } }),
|
||||
}
|
||||
const text = JSON.stringify(payload, null, 2)
|
||||
try { await navigator.clipboard.writeText(text) } catch (e) { try { const ta = document.createElement('textarea'); ta.value = text; document.body.appendChild(ta); ta.select(); document.execCommand('copy'); ta.remove() } catch (e2) { /* ignore */ } }
|
||||
setMsg('诊断已复制到剪贴板')
|
||||
} catch (e) { setMsg('诊断生成失败:' + String((e && e.message) || e)) }
|
||||
},
|
||||
}, '复制诊断'),
|
||||
),
|
||||
el('div', { className: 'iwb-section-sub' }, '已安装插件'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('input', { className: 'iwb-input iwb-grow', placeholder: '搜索已安装的插件…', value: q, onChange: function (e) { setQ(e.target.value) } }),
|
||||
@@ -250,6 +276,7 @@
|
||||
p.newer ? el('span', { className: 'iwb-plugin-tag' }, '可更新') : null,
|
||||
),
|
||||
el('div', { className: 'iwb-mk-row-desc' }, p.desc || ''),
|
||||
(rt && rt.error) ? el('div', { className: 'iwb-hint', style: { color: 'var(--iwb-err)' } }, '错误:' + rt.error) : null,
|
||||
),
|
||||
el('div', { className: 'iwb-mk-row-actions' },
|
||||
p.newer ? el('button', { className: 'iwb-btn iwb-btn-sm', disabled: !!busy, onClick: function () { act('install', p.id) } }, '更新') : null,
|
||||
|
||||
Reference in new issue
Block a user