ui: simplify helper copy and center page loading feedback

This commit is contained in:
AttilaNet
2026-11-11 21:08:48 +08:00
parent d1e7f3c717
commit e23e7586c4
25 changed files with 747 additions and 141 deletions
+5 -6
View File
@@ -10,13 +10,12 @@ const error = document.querySelector('#auth-error');
let busy = false;
let leaving = false;
function setBusy(value, message = '') {
function setBusy(value) {
busy = value;
input.disabled = value;
button.disabled = value;
form.setAttribute('aria-busy', String(value));
status.textContent = message;
status.hidden = !message;
status.hidden = !value;
}
function showError(message) {
@@ -27,7 +26,7 @@ function showError(message) {
function openWorkbench() {
leaving = true;
input.value = '';
setBusy(true, '正在进入工作台…');
setBusy(true);
location.replace(webPath('/'));
}
@@ -57,7 +56,7 @@ async function authRequest(path, body) {
}
async function checkAuth() {
setBusy(true, '正在检查登录状态…');
setBusy(true);
error.hidden = true;
try {
const auth = await authRequest('/api/auth/status');
@@ -78,7 +77,7 @@ form.addEventListener('submit', async event => {
const body = JSON.stringify({password: input.value});
input.value = '';
error.hidden = true;
setBusy(true, '正在登录…');
setBusy(true);
try {
const auth = await authRequest('/api/auth/login', body);
if (!auth.required || auth.authenticated) openWorkbench();