feat(plugins): P3 开发者模式(plugins/local/<id>/plugin.js 免签名加载)+ SDK 文档与示例插件
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
1008370733
commit
49b8cb3abd
7 files changed
+225
-7
No files matched your search
@@ -24,6 +24,7 @@
|
||||
const [msg, setMsg] = React.useState('')
|
||||
const [busy, setBusy] = React.useState('')
|
||||
const [restart, setRestart] = React.useState(false)
|
||||
|
||||
const D = (typeof window !== 'undefined') ? window.IWBDesktop : null
|
||||
const refresh = React.useCallback(async () => {
|
||||
if (!D || !D.market) { setRows([]); return }
|
||||
@@ -110,6 +111,18 @@
|
||||
return Promise.resolve(window.confirm(text))
|
||||
}
|
||||
|
||||
// 开发者模式开关(走统一存储门面,src 不得直调 localStorage)
|
||||
function pluginDevStore () {
|
||||
const L = (typeof window !== 'undefined') ? window.IWBStorageLocal : null
|
||||
return (L && typeof L.getStore === 'function') ? L.getStore() : null
|
||||
}
|
||||
function pluginDevGet () {
|
||||
try { const st = pluginDevStore(); return !!(st && st.get('iwb_plugin_dev') === true) } catch (e) { return false }
|
||||
}
|
||||
function pluginDevSet (on) {
|
||||
try { const st = pluginDevStore(); if (st) st.set('iwb_plugin_dev', !!on) } catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
// 桌面端插件管理(参考 Obsidian):搜索 + 已安装(开关/设置)+ 可安装(市场)
|
||||
function DesktopPluginsTab (props) {
|
||||
const { PluginHost, pluginItems, setPluginsRev, setTab, wRuntimePlugins } = props
|
||||
@@ -119,6 +132,9 @@
|
||||
const [msg, setMsg] = React.useState('')
|
||||
const [busy, setBusy] = React.useState('')
|
||||
const [restart, setRestart] = React.useState(false)
|
||||
const [devMode, setDevMode] = React.useState(function () {
|
||||
return pluginDevGet()
|
||||
})
|
||||
const D = (typeof window !== 'undefined') ? window.IWBDesktop : null
|
||||
const refresh = React.useCallback(async () => {
|
||||
if (!D || !D.market) { setMarket([]); return }
|
||||
@@ -177,6 +193,33 @@
|
||||
return el('div', { className: 'iwb-set-page' },
|
||||
el('div', { className: 'iwb-set-page-title' }, '插件'),
|
||||
el('div', { className: 'iwb-hint' }, '插件从市场安装到:' + dirHint + '(应用本体不再自带插件)'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('label', { className: 'iwb-check', title: '本地开发用:把插件放到 plugins/local/<id>/plugin.js' },
|
||||
el('input', {
|
||||
type: 'checkbox',
|
||||
checked: devMode,
|
||||
onChange: function (e) {
|
||||
const on = e.target.checked
|
||||
setDevMode(on)
|
||||
pluginDevSet(on)
|
||||
setMsg(on ? '已开启开发者模式,重启后加载 plugins/local/ 下的插件' : '已关闭开发者模式,重启后只加载市场安装的插件')
|
||||
},
|
||||
}),
|
||||
' 开发者模式(加载 plugins/local/<id>/plugin.js,未签名)'),
|
||||
),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('label', { className: 'iwb-check', title: '用于本地开发:把插件放到 plugins/local/<id>/plugin.js' },
|
||||
el('input', {
|
||||
type: 'checkbox', checked: devMode,
|
||||
onChange: (e) => {
|
||||
const on = e.target.checked
|
||||
setDevMode(on)
|
||||
pluginDevSet(on)
|
||||
setMsg(on ? '已开启开发者模式,重启后加载 plugins/local/ 下的插件' : '已关闭开发者模式,重启后只加载市场安装的插件')
|
||||
},
|
||||
}),
|
||||
' 开发者模式(加载 plugins/local/<id>/plugin.js,未签名)'),
|
||||
),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('input', { className: 'iwb-input iwb-grow', placeholder: '搜索已安装的插件…', value: q, onChange: (e) => setQ(e.target.value) }),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user