diff --git a/src/ui-settings-sections.js b/src/ui-settings-sections.js index 0da8b62..695c479 100644 --- a/src/ui-settings-sections.js +++ b/src/ui-settings-sections.js @@ -23,6 +23,7 @@ const [installed, setInstalled] = React.useState({}) 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 } @@ -43,7 +44,7 @@ if (!r || !r.ok) { setMsg((r && r.error) || '操作失败'); return } setMsg(kind === 'install' ? '已安装,重启应用后生效' : '已卸载,重启应用后生效') await refresh() - if (window.confirm('需要重启应用才能生效,现在重启?')) window.location.reload() + setRestart(true) } finally { setBusy('') } } if (rows === null) return el('div', { className: 'iwb-hint' }, '插件市场加载中…') @@ -182,6 +183,10 @@ ), el('button', { className: 'iwb-btn iwb-btn-sm', disabled: !!busy, onClick: () => act('install', m.id) }, busy === m.id ? '处理中…' : '安装'), )), + restart ? el('div', { className: 'iwb-row' }, + el('span', { className: 'iwb-hint', style: { flex: '1 1 auto' } }, '需要重启应用才能生效'), + el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => window.location.reload() }, '立即重启'), + ) : null, msg ? el('div', { className: 'iwb-hint' }, msg) : null, ) }