Improve auth and download UI states
This commit is contained in:
@@ -142,6 +142,26 @@
|
||||
showAppNotification(message, category === 'error' ? 'error' : 'info');
|
||||
}
|
||||
|
||||
document.querySelectorAll('[data-download-action]').forEach((button) => {
|
||||
const restoreDelay = 3000;
|
||||
const originalHtml = button.innerHTML;
|
||||
const pendingLabel = button.dataset.downloadPending || '下载中...';
|
||||
|
||||
button.addEventListener('click', () => {
|
||||
if (button.getAttribute('aria-disabled') === 'true') return;
|
||||
|
||||
button.setAttribute('aria-disabled', 'true');
|
||||
button.setAttribute('aria-busy', 'true');
|
||||
button.innerHTML = `<span class="spinner" aria-hidden="true"></span><span>${pendingLabel}</span>`;
|
||||
|
||||
window.setTimeout(() => {
|
||||
button.innerHTML = originalHtml;
|
||||
button.removeAttribute('aria-disabled');
|
||||
button.removeAttribute('aria-busy');
|
||||
}, restoreDelay);
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
{% block scripts %}{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user