Replace native confirm dialogs with custom styled modal
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user