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:
@ -95,9 +95,9 @@
|
||||
loginInProgress = false;
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = '登录';
|
||||
if (confirm(resp.message + '\n\n确认登录将撤销注销并恢复账号。')) {
|
||||
doConfirmRestore(email, password);
|
||||
}
|
||||
showConfirm('确认', resp.message + '\n\n确认登录将撤销注销并恢复账号。').then(function(ok) {
|
||||
if (ok) doConfirmRestore(email, password);
|
||||
});
|
||||
} else if (xhr.status === 200 && resp && resp.success) {
|
||||
window.MetaLab.toast(toast, '登录成功', false);
|
||||
setTimeout(function () {
|
||||
|
||||
@ -119,21 +119,23 @@
|
||||
|
||||
function removeFromFolder(folderId) {
|
||||
if (loading) return;
|
||||
if (!confirm('确定取消收藏吗?')) return;
|
||||
loading = true;
|
||||
api('DELETE', '/api/folders/' + folderId + '/posts/' + postId)
|
||||
.then(function(d) {
|
||||
loading = false;
|
||||
if (d.success) {
|
||||
currentFolderId = null;
|
||||
updateBtn(false);
|
||||
if (favCountEl) favCountEl.textContent = Math.max(0, (parseInt(favCountEl.textContent) || 0) - 1);
|
||||
hideModal();
|
||||
} else {
|
||||
showConfirm('确认', '确定取消收藏吗?').then(function(ok) {
|
||||
if (!ok) return;
|
||||
loading = true;
|
||||
api('DELETE', '/api/folders/' + folderId + '/posts/' + postId)
|
||||
.then(function(d) {
|
||||
loading = false;
|
||||
if (d.success) {
|
||||
currentFolderId = null;
|
||||
updateBtn(false);
|
||||
if (favCountEl) favCountEl.textContent = Math.max(0, (parseInt(favCountEl.textContent) || 0) - 1);
|
||||
hideModal();
|
||||
} else {
|
||||
alert(d.message || '操作失败');
|
||||
}
|
||||
})
|
||||
.catch(function() { loading = false; });
|
||||
});
|
||||
}
|
||||
|
||||
function createAndAdd(name) {
|
||||
|
||||
@ -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('请求失败'); });
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user