Router.register('/login', async () => { setTimeout(() => { const btn = document.getElementById('login-btn'); btn?.addEventListener('click', async () => { const u = document.getElementById('login-username').value; const p = document.getElementById('login-password').value; try { await API.login(u, p); await API.me().then(user => { const info = document.getElementById('user-info'); if (info) info.textContent = user?.username || '未登录'; }).catch(()=>{}); location.href = '#/dashboard'; } catch(e) {} }); }, 0); return `
管理员登录
`; });