feat: 取消跳过确认弹窗,简化操作逻辑

This commit is contained in:
QLHazyCoder
2026-04-11 17:27:27 +08:00
parent 1f91f6fcee
commit 5fec876a9f
+26 -23
View File
@@ -299,7 +299,7 @@ function updateSaveButtonState() {
function scheduleSettingsAutoSave() { function scheduleSettingsAutoSave() {
clearTimeout(settingsAutoSaveTimer); clearTimeout(settingsAutoSaveTimer);
settingsAutoSaveTimer = setTimeout(() => { settingsAutoSaveTimer = setTimeout(() => {
saveSettings({ silent: true }).catch(() => {}); saveSettings({ silent: true }).catch(() => { });
}, 500); }, 500);
} }
@@ -724,18 +724,15 @@ async function maybeTakeoverAutoRun(actionLabel) {
} }
async function handleSkipStep(step) { async function handleSkipStep(step) {
if (!(await maybeTakeoverAutoRun(`跳过步骤 ${step}`))) { if (isAutoRunPausedPhase()) {
return; const takeoverResponse = await chrome.runtime.sendMessage({
} type: 'TAKEOVER_AUTO_RUN',
source: 'sidepanel',
const confirmed = await openConfirmModal({ payload: {},
title: '跳过步骤', });
message: `这不会真正执行步骤 ${step},只会直接跳过该步骤并放行后续步骤。是否继续?`, if (takeoverResponse?.error) {
confirmLabel: `跳过步骤 ${step}`, throw new Error(takeoverResponse.error);
confirmVariant: 'btn-primary', }
});
if (!confirmed) {
return;
} }
const response = await chrome.runtime.sendMessage({ const response = await chrome.runtime.sendMessage({
@@ -797,7 +794,7 @@ document.querySelectorAll('.step-btn').forEach(btn => {
}); });
btnFetchEmail.addEventListener('click', async () => { btnFetchEmail.addEventListener('click', async () => {
await fetchDuckEmail().catch(() => {}); await fetchDuckEmail().catch(() => { });
}); });
btnTogglePassword.addEventListener('click', () => { btnTogglePassword.addEventListener('click', () => {
@@ -815,7 +812,7 @@ btnSaveSettings.addEventListener('click', async () => {
showToast('配置已是最新', 'info', 1400); showToast('配置已是最新', 'info', 1400);
return; return;
} }
await saveSettings({ silent: false }).catch(() => {}); await saveSettings({ silent: false }).catch(() => { });
}); });
btnStop.addEventListener('click', async () => { btnStop.addEventListener('click', async () => {
@@ -929,7 +926,7 @@ inputVpsUrl.addEventListener('input', () => {
scheduleSettingsAutoSave(); scheduleSettingsAutoSave();
}); });
inputVpsUrl.addEventListener('blur', () => { inputVpsUrl.addEventListener('blur', () => {
saveSettings({ silent: true }).catch(() => {}); saveSettings({ silent: true }).catch(() => { });
}); });
inputVpsPassword.addEventListener('input', () => { inputVpsPassword.addEventListener('input', () => {
@@ -937,7 +934,7 @@ inputVpsPassword.addEventListener('input', () => {
scheduleSettingsAutoSave(); scheduleSettingsAutoSave();
}); });
inputVpsPassword.addEventListener('blur', () => { inputVpsPassword.addEventListener('blur', () => {
saveSettings({ silent: true }).catch(() => {}); saveSettings({ silent: true }).catch(() => { });
}); });
inputPassword.addEventListener('input', () => { inputPassword.addEventListener('input', () => {
@@ -946,13 +943,13 @@ inputPassword.addEventListener('input', () => {
scheduleSettingsAutoSave(); scheduleSettingsAutoSave();
}); });
inputPassword.addEventListener('blur', () => { inputPassword.addEventListener('blur', () => {
saveSettings({ silent: true }).catch(() => {}); saveSettings({ silent: true }).catch(() => { });
}); });
selectMailProvider.addEventListener('change', () => { selectMailProvider.addEventListener('change', () => {
updateMailProviderUI(); updateMailProviderUI();
markSettingsDirty(true); markSettingsDirty(true);
saveSettings({ silent: true }).catch(() => {}); saveSettings({ silent: true }).catch(() => { });
}); });
inputInbucketMailbox.addEventListener('input', () => { inputInbucketMailbox.addEventListener('input', () => {
@@ -960,7 +957,7 @@ inputInbucketMailbox.addEventListener('input', () => {
scheduleSettingsAutoSave(); scheduleSettingsAutoSave();
}); });
inputInbucketMailbox.addEventListener('blur', () => { inputInbucketMailbox.addEventListener('blur', () => {
saveSettings({ silent: true }).catch(() => {}); saveSettings({ silent: true }).catch(() => { });
}); });
inputInbucketHost.addEventListener('input', () => { inputInbucketHost.addEventListener('input', () => {
@@ -968,12 +965,12 @@ inputInbucketHost.addEventListener('input', () => {
scheduleSettingsAutoSave(); scheduleSettingsAutoSave();
}); });
inputInbucketHost.addEventListener('blur', () => { inputInbucketHost.addEventListener('blur', () => {
saveSettings({ silent: true }).catch(() => {}); saveSettings({ silent: true }).catch(() => { });
}); });
inputAutoSkipFailures.addEventListener('change', () => { inputAutoSkipFailures.addEventListener('change', () => {
markSettingsDirty(true); markSettingsDirty(true);
saveSettings({ silent: true }).catch(() => {}); saveSettings({ silent: true }).catch(() => { });
}); });
// ============================================================ // ============================================================
@@ -1009,7 +1006,7 @@ chrome.runtime.onMessage.addListener((message) => {
} }
} }
} }
).catch(() => {}); ).catch(() => { });
break; break;
} }
@@ -1105,7 +1102,13 @@ btnTheme.addEventListener('click', () => {
initializeManualStepActions(); initializeManualStepActions();
initTheme(); initTheme();
updateToastOffset();
updateSaveButtonState(); updateSaveButtonState();
window.addEventListener('resize', updateToastOffset);
window.addEventListener('load', updateToastOffset);
if (document.fonts?.ready) {
document.fonts.ready.then(updateToastOffset).catch(() => { });
}
restoreState().then(() => { restoreState().then(() => {
syncPasswordToggleLabel(); syncPasswordToggleLabel();
syncVpsUrlToggleLabel(); syncVpsUrlToggleLabel();