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:
2026-06-03 01:25:12 +08:00
parent 864a488ee0
commit 6c9a4414cb
11 changed files with 42 additions and 75 deletions

View File

@ -169,10 +169,10 @@ async function handleSubmit(e) {
try {
const postId = document.getElementById('postId')?.value
const title = document.getElementById('postTitle')?.value.trim()
if (!title) { alert('请输入标题'); return }
if (!title) { showToast('请输入标题', 'warning'); return }
const body = vditor ? vditor.getValue() : ''
if (!body.trim()) { alert('请输入正文'); return }
if (!body.trim()) { showToast('请输入正文', 'warning'); return }
const isEdit = !!postId
const url = isEdit ? '/api/studio/posts/' + postId : '/api/studio/posts'
@ -197,10 +197,10 @@ async function handleSubmit(e) {
window.location.href = '/studio/posts'
}
} else {
alert(data.message || '操作失败')
showToast(data.message || '操作失败', 'error')
}
} catch (err) {
alert('请求失败,请重试')
showToast('请求失败,请重试', 'error')
} finally {
submitting = false
if (submitBtn) {