360 lines
11 KiB
HTML
360 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>登录 - XClaw AI</title>
|
|
|
|
<!-- Global Styles -->
|
|
<link rel="stylesheet" href="/static/css/style.css">
|
|
|
|
<!-- Fonts -->
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
|
|
|
<!-- Page-Specific Styles -->
|
|
<style>
|
|
body {
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
.login-container {
|
|
width: 100%;
|
|
max-width: 420px;
|
|
background: var(--panel-strong);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 48px 40px;
|
|
box-shadow: var(--shadow-lg);
|
|
backdrop-filter: blur(18px);
|
|
}
|
|
|
|
.login-header {
|
|
text-align: center;
|
|
margin-bottom: 40px;
|
|
}
|
|
|
|
.login-logo {
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.login-logo svg {
|
|
width: 48px;
|
|
height: 48px;
|
|
color: var(--primary);
|
|
}
|
|
|
|
.login-title {
|
|
font-size: 28px;
|
|
font-weight: 700;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.login-form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20px;
|
|
}
|
|
|
|
.form-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.form-label {
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.form-input {
|
|
width: 100%;
|
|
padding: 12px 16px;
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-md);
|
|
font-size: 15px;
|
|
font-family: inherit;
|
|
color: var(--text-primary);
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.form-input:focus {
|
|
outline: none;
|
|
background: var(--bg-primary);
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
|
|
}
|
|
|
|
.form-input::placeholder {
|
|
color: var(--text-tertiary);
|
|
}
|
|
|
|
.code-input-group {
|
|
display: flex;
|
|
gap: 12px;
|
|
}
|
|
|
|
.code-input-group .form-input {
|
|
flex: 1;
|
|
}
|
|
|
|
.send-code-btn {
|
|
padding: 12px 20px;
|
|
background: rgba(126, 200, 255, 0.08);
|
|
border: 1px solid var(--primary);
|
|
border-radius: var(--radius-md);
|
|
color: var(--primary);
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
white-space: nowrap;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.send-code-btn:hover:not(:disabled) {
|
|
background: rgba(126, 200, 255, 0.14);
|
|
}
|
|
|
|
.send-code-btn:disabled {
|
|
opacity: 0.4;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.login-btn {
|
|
width: 100%;
|
|
padding: 14px;
|
|
background: linear-gradient(135deg, #8fd7ff, #63e6be);
|
|
border: none;
|
|
border-radius: var(--radius-md);
|
|
color: #071018;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
box-shadow: 0 10px 24px rgba(49, 132, 189, 0.22);
|
|
}
|
|
|
|
.login-btn:hover:not(:disabled) {
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.login-btn:disabled {
|
|
opacity: 0.4;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.error-message {
|
|
padding: 12px 16px;
|
|
background: var(--error-light);
|
|
border: 1px solid var(--error);
|
|
border-radius: var(--radius-md);
|
|
color: var(--error);
|
|
font-size: 13px;
|
|
text-align: center;
|
|
}
|
|
|
|
.login-footer {
|
|
margin-top: 24px;
|
|
text-align: center;
|
|
font-size: 12px;
|
|
color: var(--text-tertiary);
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.login-container {
|
|
padding: 32px 24px;
|
|
}
|
|
|
|
.login-title {
|
|
font-size: 24px;
|
|
}
|
|
|
|
.code-input-group {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.send-code-btn {
|
|
width: 100%;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="app" class="login-page">
|
|
<div class="login-container">
|
|
<div class="login-header">
|
|
<div class="login-logo">
|
|
<svg viewBox="0 0 24 24" fill="none">
|
|
<path d="M3 13h8V3H3v10zm0 8h8v-6H3v6zm10 0h8V11h-8v10zm0-18v6h8V3h-8z" fill="currentColor"/>
|
|
</svg>
|
|
</div>
|
|
<h1 class="login-title">XClaw AI</h1>
|
|
</div>
|
|
|
|
<form class="login-form" @submit.prevent="handleLogin">
|
|
<div class="form-group">
|
|
<label class="form-label">手机号</label>
|
|
<input
|
|
type="tel"
|
|
class="form-input"
|
|
v-model="phone"
|
|
placeholder="请输入手机号"
|
|
maxlength="11"
|
|
required
|
|
>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">验证码</label>
|
|
<div class="code-input-group">
|
|
<input
|
|
type="text"
|
|
class="form-input"
|
|
v-model="code"
|
|
placeholder="请输入验证码"
|
|
maxlength="6"
|
|
required
|
|
>
|
|
<button
|
|
type="button"
|
|
class="send-code-btn"
|
|
@click="sendCode"
|
|
:disabled="countdown > 0 || !isPhoneValid"
|
|
>
|
|
{{ countdown > 0 ? `${countdown}秒后重试` : '发送验证码' }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="errorMessage" class="error-message">
|
|
{{ errorMessage }}
|
|
</div>
|
|
|
|
<button
|
|
type="submit"
|
|
class="login-btn"
|
|
:disabled="loading || !isFormValid"
|
|
>
|
|
{{ loading ? '登录中...' : '登录' }}
|
|
</button>
|
|
</form>
|
|
|
|
<div class="login-footer">
|
|
登录即表示同意服务条款和隐私政策
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js"></script>
|
|
<script>
|
|
const { createApp } = Vue;
|
|
|
|
createApp({
|
|
data() {
|
|
return {
|
|
phone: '',
|
|
code: '',
|
|
countdown: 0,
|
|
loading: false,
|
|
errorMessage: ''
|
|
};
|
|
},
|
|
computed: {
|
|
isPhoneValid() {
|
|
return /^1[3-9]\d{9}$/.test(this.phone);
|
|
},
|
|
isFormValid() {
|
|
return this.isPhoneValid && this.code.length === 6;
|
|
}
|
|
},
|
|
methods: {
|
|
async sendCode() {
|
|
if (!this.isPhoneValid) {
|
|
this.errorMessage = '请输入正确的手机号';
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('/api/auth/send-code', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
phone: this.phone
|
|
})
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
this.errorMessage = '';
|
|
this.countdown = 60;
|
|
this.startCountdown();
|
|
alert('验证码已发送');
|
|
} else {
|
|
this.errorMessage = data.message || '发送失败';
|
|
}
|
|
} catch (error) {
|
|
console.error('发送验证码失败:', error);
|
|
this.errorMessage = '发送失败,请稍后重试';
|
|
}
|
|
},
|
|
|
|
startCountdown() {
|
|
const timer = setInterval(() => {
|
|
this.countdown--;
|
|
if (this.countdown <= 0) {
|
|
clearInterval(timer);
|
|
}
|
|
}, 1000);
|
|
},
|
|
|
|
async handleLogin() {
|
|
if (!this.isFormValid) {
|
|
return;
|
|
}
|
|
|
|
this.loading = true;
|
|
this.errorMessage = '';
|
|
|
|
try {
|
|
const response = await fetch('/api/auth/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
phone: this.phone,
|
|
code: this.code
|
|
})
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success && data.token) {
|
|
localStorage.setItem('token', data.token);
|
|
window.location.href = '/app';
|
|
} else {
|
|
this.errorMessage = data.message || '登录失败';
|
|
}
|
|
} catch (error) {
|
|
console.error('登录失败:', error);
|
|
this.errorMessage = '登录失败,请稍后重试';
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
}
|
|
}
|
|
}).mount('#app');
|
|
</script>
|
|
</body>
|
|
</html>
|