feat: prompt/confirm 替换为自定义弹窗

- shared/utils.js 新增 showConfirm()/showPrompt() 通用函数(inline CSS,无需额外样式)
- admin/common.js 移除重复 showConfirm(),统一使用 utils.js
- admin/posts.js: 3 处 confirm/prompt 替换(审核/退回/锁定)
- admin/comments.js: 1 处 confirm 替换
- settings/index.html: 4 处 confirm + 1 处 prompt 替换
- studio/posts.html + drafts.html: 3 处 confirm 替换
- post-view.js + login.js + post-favorite.js: 3 处 confirm 替换
This commit is contained in:
2026-06-02 20:11:48 +08:00
parent 2e6e7fc057
commit c73b131b83
10 changed files with 318 additions and 243 deletions

View File

@ -29,20 +29,22 @@
var submitBtn = document.getElementById('submitAuditBtn');
if (submitBtn) {
submitBtn.addEventListener('click', function() {
if (!confirm('确认提交审核?审核通过后将公开发布。')) return;
fetch('/api/posts/' + submitBtn.dataset.id + '/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCSRFToken()
}
})
.then(function(r) { return r.json(); })
.then(function(d) {
if (d.success) { window.location.reload(); }
else { alert(d.message || '提交失败'); }
})
.catch(function() { alert('请求失败'); });
showConfirm('确认', '确认提交审核?审核通过后将公开发布。').then(function(ok) {
if (!ok) return;
fetch('/api/posts/' + submitBtn.dataset.id + '/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCSRFToken()
}
})
.then(function(r) { return r.json(); })
.then(function(d) {
if (d.success) { window.location.reload(); }
else { alert(d.message || '提交失败'); }
})
.catch(function() { alert('请求失败'); });
});
});
}
})();