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:
@ -705,7 +705,7 @@ function createFolder() {
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({name: name, is_public: false})
|
||||
}).then(function(r) { return r.json(); }).then(function(d) {
|
||||
if (d.success) { location.reload(); } else { alert(d.message || '创建失败'); }
|
||||
if (d.success) { location.reload(); } else { showToast(d.message || '创建失败', 'error'); }
|
||||
});
|
||||
}
|
||||
|
||||
@ -743,7 +743,7 @@ document.querySelectorAll('#privacy-follow-list, #privacy-follower-list').forEac
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({field: field, value: value})
|
||||
}).then(function(r){return r.json()}).then(function(d){
|
||||
if(!d.success) { this.checked=!value; alert(d.message||'保存失败'); }
|
||||
if(!d.success) { this.checked=!value; showToast(d.message||'保存失败', 'error'); }
|
||||
}.bind(this));
|
||||
});
|
||||
});
|
||||
|
||||
@ -73,7 +73,7 @@ function submitPost(id) {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.message || '提交失败');
|
||||
showToast(data.message || '提交失败', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -94,7 +94,7 @@ function deletePost(id) {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.message || '删除失败');
|
||||
showToast(data.message || '删除失败', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -94,7 +94,7 @@ function deletePost(id) {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert(data.message || '删除失败');
|
||||
showToast(data.message || '删除失败', 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user