fix(user): align badge modals with reference theme

This commit is contained in:
kate522 committed 2026-10-29 17:38:10 +08:00
1 parent 8e9d3a7e49
commit 1c501ff713
17 files changed
+931 -313

No files matched your search

+19 -7
View File
@@ -1,8 +1,7 @@
/**
* Server-rendered user medal actions.
*
* Mirrors the legacy admin-ajax lifecycle: mutate, close the dialog, then
* reload the page so every server-rendered medal surface is in sync.
* Badge mutations close only the active dialog, matching the reference theme.
*
* @package AKSRT
*/
@@ -16,7 +15,7 @@
};
function notice(message, type) {
if (typeof window.notyf === 'function') window.notyf(message, type);
if (typeof window.notyf === 'function') window.notyf(message, type, '', 'badge-action');
}
document.addEventListener('click', function (event) {
@@ -30,8 +29,22 @@
if (!action || !slug || !nonce) return;
event.preventDefault();
var modal = button.closest('.aksrt-modal-runtime');
var label = button.innerHTML;
button.classList.add('is-loading');
button.setAttribute('aria-busy', 'true');
button.setAttribute('aria-disabled', 'true');
button.setAttribute('disabled', '');
button.innerHTML = '<i class="loading mr6" aria-hidden="true"></i><text>请稍候</text>';
notice('正在处理,请稍候…', 'load');
function restoreButton() {
button.classList.remove('is-loading');
button.removeAttribute('aria-busy');
button.removeAttribute('aria-disabled');
button.removeAttribute('disabled');
button.innerHTML = label;
}
var form = new URLSearchParams();
form.set('action', action);
@@ -48,12 +61,11 @@
return response.json();
}).then(function (json) {
if (!json || !json.success) throw new Error((json && json.data && json.data.message) || '操作失败');
restoreButton();
notice((json.data && json.data.message) || '操作成功', 'success');
window.AksrtModalRuntime.close('badge-action');
window.setTimeout(function () { window.location.reload(); }, 120);
if (window.AksrtModalRuntime.getActive() === modal) window.AksrtModalRuntime.close('badge-action');
}).catch(function (error) {
button.classList.remove('is-loading');
button.removeAttribute('aria-busy');
restoreButton();
notice(error.message || '网络错误', 'danger');
});
});