()
| 61 | export { closeSettings }; |
| 62 | |
| 63 | export function initSettings() { |
| 64 | $('btn-settings').addEventListener('click', openSettings); |
| 65 | $('settings-close').addEventListener('click', closeSettings); |
| 66 | $('settings-overlay').addEventListener('click', e => { |
| 67 | if (e.target === $('settings-overlay')) closeSettings(); |
| 68 | }); |
| 69 | |
| 70 | document.querySelectorAll('input[name="approval-mode"]').forEach(radio => { |
| 71 | radio.addEventListener('change', async (e) => { |
| 72 | const mode = e.target.value; |
| 73 | if (mode === 'all') { |
| 74 | const ok = await showConfirm( |
| 75 | '全部自动审批将允许所有命令(包括 Bash、系统命令)无需确认直接执行,这可能存在风险。确定要开启吗?' |
| 76 | ); |
| 77 | if (!ok) { |
| 78 | const prev = document.querySelector(`input[name="approval-mode"][value="${approvalMode}"]`); |
| 79 | if (prev) prev.checked = true; |
| 80 | return; |
| 81 | } |
| 82 | } else if (mode === 'partial') { |
| 83 | const ok = await showConfirm( |
| 84 | '部分自动审批将自动放行 Read、Write、Edit、Glob、Grep 命令,无需手动确认。确定要开启吗?' |
| 85 | ); |
| 86 | if (!ok) { |
| 87 | const prev = document.querySelector(`input[name="approval-mode"][value="${approvalMode}"]`); |
| 88 | if (prev) prev.checked = true; |
| 89 | return; |
| 90 | } |
| 91 | } |
| 92 | setApprovalMode(mode); |
| 93 | }); |
| 94 | }); |
| 95 | |
| 96 | document.querySelectorAll('input[name="theme-mode"]').forEach(radio => { |
| 97 | radio.addEventListener('change', (e) => { |
| 98 | applyTheme(e.target.value); |
| 99 | }); |
| 100 | }); |
| 101 | } |
nothing calls this directly
no test coverage detected