diff --git a/static/index.html b/static/index.html index d78e8de..a41dfbb 100644 --- a/static/index.html +++ b/static/index.html @@ -393,6 +393,19 @@ + +
+
+
+

确认操作

+

+
+ + +
+
+
+
diff --git a/static/script.js b/static/script.js index 8244986..7043785 100644 --- a/static/script.js +++ b/static/script.js @@ -498,7 +498,10 @@ class MailManager { } async deleteAccount(email) { - if (!confirm(`确定要删除账号 ${email} 吗?`)) return; + this.showConfirm(`确定要删除账号 ${email} 吗?`, () => this._doDeleteAccount(email), '删除确认'); + } + + async _doDeleteAccount(email) { try { const resp = await fetch(`/api/account/${encodeURIComponent(email)}`, { method: 'DELETE' }); @@ -737,9 +740,23 @@ class MailManager { const msg = isReceived ? `确定将 ${email} 的退款状态改为【未到账】吗?` : `确定将 ${email} 标记为【退款已到账】吗?`; - if (confirm(msg)) { - this.toggleRefundReceived(email); - } + this.showConfirm(msg, () => this.toggleRefundReceived(email)); + } + + showConfirm(message, onOk, title = '确认操作') { + const modal = document.getElementById('confirmModal'); + document.getElementById('confirmTitle').textContent = title; + document.getElementById('confirmMessage').textContent = message; + modal.classList.add('show'); + + const okBtn = document.getElementById('confirmOkBtn'); + const cancelBtn = document.getElementById('confirmCancelBtn'); + const close = () => modal.classList.remove('show'); + + const onConfirm = () => { close(); onOk(); }; + okBtn.onclick = onConfirm; + cancelBtn.onclick = close; + modal.onclick = (e) => { if (e.target === modal) close(); }; } showCredentialModal(email) {