Files
MC_Report/public/js/pages/login.js
canglan 8c5ce78fd0 chore: add AGPLv3 copyright header to all source files
- 52 JS files (backend + public/js): header with
  Copyright (C) 2026 Sea Network Technology Studio
  Author: CangLan <admin@sea-studio.top>
  + AGPLv3 notice
- idempotent (skips if header present), all syntax-checked
2026-08-19 20:27:05 +08:00

58 lines
2.4 KiB
JavaScript

/*
* MC Report System
* Copyright (C) 2026 Sea Network Technology Studio
* Author: CangLan <admin@sea-studio.top>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const LoginPage = {
async render() {
return `
<div class="pub-card">
<div class="logo"><i class="fas fa-shield-halved"></i><h2>欢迎回来</h2><p>登录您的账号</p></div>
<form id="login-form">
<div class="form-group"><input id="lu" placeholder="用户名" required autofocus></div>
<div class="form-group"><input type="password" id="lp" placeholder="密码" required></div>
<div id="le" class="alert alert-e hidden"></div>
<button type="submit" class="btn btn-p btn-lg w-full"><i class="fas fa-sign-in-alt"></i> 登录</button>
</form>
<div style="margin-top:18px;text-align:center;font-size:13px">
<a href="#/register" style="color:var(--p);text-decoration:none;font-weight:600">还没有账号?立即注册</a>
<span style="color:var(--g4);margin:0 10px">|</span>
<a href="#/home" style="color:var(--g5);text-decoration:none">匿名提交</a>
</div>
</div>`;
},
mount() {
document.getElementById('login-form').addEventListener('submit', async e => {
e.preventDefault();
const btn = e.target.querySelector('button');
btn.disabled = true;
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 登录中...';
try {
await Auth.login(document.getElementById('lu').value.trim(), document.getElementById('lp').value.trim());
App.afterLogin();
} catch (err) {
const el = document.getElementById('le');
el.textContent = err.message;
el.classList.remove('hidden');
btn.disabled = false;
btn.innerHTML = '<i class="fas fa-sign-in-alt"></i> 登录';
}
});
}
};