Initial commit: gamer project

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lizhilun
2026-03-12 11:23:10 +08:00
co-authored by Claude Opus 4.6
commit a0d7bfdc3d
26 changed files with 5410 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
async function doLogin() {
const user = document.getElementById('loginUser').value.trim();
const pass = document.getElementById('loginPass').value.trim();
if (!user || !pass) { document.getElementById('loginError').textContent = '请输入用户名和密码'; return; }
try {
const res = await fetch(API + '/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: user, password: pass })
});
const data = await res.json();
if (!res.ok) { document.getElementById('loginError').textContent = data.error; return; }
token = data.token;
username = data.username;
localStorage.setItem('token', token);
localStorage.setItem('username', username);
showPage('homePage');
} catch (e) {
document.getElementById('loginError').textContent = '网络错误';
}
}
function doLogout() {
token = null;
username = null;
localStorage.removeItem('token');
localStorage.removeItem('username');
showPage('loginPage');
}