refactor: 全局移除浏览器 alert 弹窗,统一使用页面内 showToast 通知
- 替换全部 11 个文件中 36 处 alert() 为 showToast() - API 错误/异常使用 showToast(msg, 'error'),3秒自动消失 - 表单校验提示使用 showToast(msg, 'warning'),3秒自动消失 - 成功确认使用 showToast(msg, 'success'),3秒自动消失 - 移除 post-energize.js 中与全局 showToast 冲突的本地实现 - 删除 posts.css 中已失去引用的 .energize-toast 样式 - 保留 showConfirm() 自定义确认弹窗(需用户确认的操作)
This commit is contained in:
@ -201,7 +201,7 @@
|
||||
var input = document.getElementById('replyInput-' + id);
|
||||
if (!input) return;
|
||||
var body = input.value.trim();
|
||||
if (!body) { alert('请输入回复内容'); return; }
|
||||
if (!body) { showToast('请输入回复内容', 'warning'); return; }
|
||||
|
||||
btn.disabled = true;
|
||||
api('POST', '/api/comments/' + id + '/reply', { body: body })
|
||||
@ -236,12 +236,12 @@
|
||||
}
|
||||
updateTotalCount(1);
|
||||
} else {
|
||||
alert(d.message || '回复失败');
|
||||
showToast(d.message || '回复失败', 'error');
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
btn.disabled = false;
|
||||
alert('请求失败');
|
||||
showToast('请求失败', 'error');
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -406,7 +406,7 @@
|
||||
if (commentSubmitBtn) {
|
||||
commentSubmitBtn.addEventListener('click', function() {
|
||||
var body = commentInput.value.trim();
|
||||
if (!body) { alert('请输入评论内容'); return; }
|
||||
if (!body) { showToast('请输入评论内容', 'warning'); return; }
|
||||
|
||||
commentSubmitBtn.disabled = true;
|
||||
api('POST', '/api/posts/' + postId + '/comments', { body: body })
|
||||
@ -419,12 +419,12 @@
|
||||
loadComments(currentPage);
|
||||
updateTotalCount(1);
|
||||
} else {
|
||||
alert(d.message || '发表失败');
|
||||
showToast(d.message || '发表失败', 'error');
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
commentSubmitBtn.disabled = false;
|
||||
alert('请求失败');
|
||||
showToast('请求失败', 'error');
|
||||
});
|
||||
});
|
||||
|
||||
@ -483,14 +483,14 @@
|
||||
input.focus();
|
||||
input.selectionStart = input.selectionEnd = start + imgUrl.length;
|
||||
} else {
|
||||
alert(d.message || '上传失败');
|
||||
showToast(d.message || '上传失败', 'error');
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
uploadLabel.style.pointerEvents = 'auto';
|
||||
uploadLabel.style.opacity = '1';
|
||||
uploadLabel.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="16" height="16"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg> 图片';
|
||||
alert('上传失败');
|
||||
showToast('上传失败', 'error');
|
||||
});
|
||||
|
||||
imageUploadInput.value = '';
|
||||
|
||||
Reference in New Issue
Block a user