const form = document.getElementById('loginForm'); const tokenInput = document.getElementById('tokenInput'); const loginError = document.getElementById('loginError'); form.addEventListener('submit', async (event) => { event.preventDefault(); loginError.textContent = ''; const response = await fetch('/api/auth/login', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ token: tokenInput.value }) }); if (response.ok) { window.location.href = '/'; return; } loginError.textContent = response.status === 429 ? '尝试次数过多' : 'Token 无效'; });