80 lines
3.3 KiB
HTML
80 lines
3.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
|
<title>GameParlor · 登录</title>
|
|
<link rel="stylesheet" href="/app.css">
|
|
<script src="/js/vendor/tailwind.min.js"></script>
|
|
<script defer src="/js/vendor/alpine.min.js"></script>
|
|
</head>
|
|
<body class="gp-auth min-h-screen flex items-center justify-center p-4"
|
|
style="background: radial-gradient(1200px 600px at 50% -10%, rgba(0,212,255,.12), transparent 60%), #0f0f11;">
|
|
<div x-data="authApp()" class="w-full max-w-md">
|
|
<div class="card p-8 page-fade">
|
|
<div class="flex items-center gap-3 mb-8">
|
|
<div class="w-11 h-11 rounded-xl bg-[#00d4ff] text-[#06242b] flex items-center justify-center text-xl font-bold">G</div>
|
|
<div>
|
|
<h1 class="text-xl font-bold">GameParlor</h1>
|
|
<p class="text-xs text-[#6b6b78]">电玩店自助管理与消费系统</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex gap-1 p-1 rounded-xl bg-[#16161a] mb-6">
|
|
<button @click="mode='login'" :class="mode==='login' ? 'bg-[#00d4ff] text-[#06242b]' : 'text-[#9a9aa5]'"
|
|
class="flex-1 py-2 rounded-lg text-sm font-medium transition-colors">登录</button>
|
|
<button @click="mode='register'" :class="mode==='register' ? 'bg-[#00d4ff] text-[#06242b]' : 'text-[#9a9aa5]'"
|
|
class="flex-1 py-2 rounded-lg text-sm font-medium transition-colors">注册</button>
|
|
</div>
|
|
|
|
<form @submit.prevent="submit" class="space-y-4">
|
|
<div>
|
|
<label class="label">用户名</label>
|
|
<input x-model="form.username" class="input" placeholder="请输入用户名" autocomplete="username" required>
|
|
</div>
|
|
<div>
|
|
<label class="label">密码</label>
|
|
<input x-model="form.password" type="password" class="input" placeholder="请输入密码"
|
|
autocomplete="current-password" required>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary w-full" :disabled="loading">
|
|
<span x-show="!loading" x-text="mode==='login' ? '登 录' : '注 册'"></span>
|
|
<span x-show="loading">处理中...</span>
|
|
</button>
|
|
</form>
|
|
|
|
<p class="remark mt-6 text-center">默认管理员:admin / admin123</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/app.js"></script>
|
|
<script>
|
|
function authApp() {
|
|
return {
|
|
mode: 'login',
|
|
loading: false,
|
|
form: { username: '', password: '' },
|
|
async submit() {
|
|
this.loading = true;
|
|
try {
|
|
const path = this.mode === 'login' ? '/api/auth/login' : '/api/auth/register';
|
|
const data = await api(path, { method: 'POST', body: JSON.stringify(this.form) });
|
|
GP.setToken(data.token);
|
|
GP.setUser({ userId: data.userId, username: data.username, role: data.role });
|
|
toast(this.mode === 'login' ? '登录成功' : '注册成功', 'success');
|
|
const isAdmin = data.role === 'ADMIN';
|
|
setTimeout(() => {
|
|
window.location.href = isAdmin ? '/admin/dashboard.html' : '/player/dashboard.html';
|
|
}, 400);
|
|
} catch (e) {
|
|
// toast already shown
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|