Files
abot/admin/dashboard/templates/login.html
T
2026-02-27 12:22:07 +08:00

202 lines
7.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">
<title>登录 - A-BOT管理后台</title>
<!-- 添加favicon -->
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon">
<!-- Element UI CSS -->
<link rel="stylesheet" href="/static/css/element-ui/theme-chalk/index.min.css">
<!-- 图表库 -->
<script src="/static/js/chart.js"></script>
<!-- Vue.js -->
<script src="/static/js/vue.js"></script>
<!-- Element UI JS -->
<script src="/static/js/element-ui/index.min.js"></script>
<!-- Axios -->
<script src="/static/js/axios.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
background: #0a0b0f;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.login-container {
width: 400px;
padding: 40px 36px 32px 36px;
background-color: #11151f;
border: 1px solid #1e2535;
border-radius: 12px;
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
display: flex;
flex-direction: column;
align-items: center;
animation: fadeIn 0.8s;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-30px);}
to { opacity: 1; transform: translateY(0);}
}
.login-title {
text-align: center;
margin-bottom: 32px;
color: #8b5cf6;
font-size: 28px;
font-weight: 700;
letter-spacing: 2px;
}
.login-form {
width: 100%;
margin-top: 10px;
}
.el-input__inner {
border-radius: 6px;
border: 1.5px solid #252d42;
background: #141a28;
color: #e2e8f0;
transition: border-color 0.2s;
}
.el-input__inner:focus {
border-color: #8b5cf6;
box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}
.el-form-item__content {
margin-left: 0 !important;
}
.login-button {
width: 100%;
margin-top: 10px;
background: #7c3aed;
border: none;
color: #ffffff;
font-weight: 600;
border-radius: 6px;
box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
transition: background 0.2s;
}
.login-button:hover, .login-button:focus {
background: #8b5cf6;
}
.error-message {
color: #f87171;
margin-top: 18px;
text-align: center;
font-size: 15px;
}
.login-logo {
width: 60px;
height: 60px;
margin-bottom: 18px;
border-radius: 50%;
box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
background: #141a28;
border: 1px solid #252d42;
display: flex;
align-items: center;
justify-content: center;
}
.login-footer {
margin-top: 28px;
text-align: center;
color: #94a3b8;
font-size: 13px;
letter-spacing: 1px;
}
</style>
</head>
<body>
<div id="app">
<div class="login-container">
<div class="login-logo">
<img src="/static/logo.png" alt="Logo" style="width:38px;height:38px;">
</div>
<h2 class="login-title">A-BOT管理后台</h2>
<el-form class="login-form" ref="loginForm" :model="loginForm" :rules="rules" label-width="0px">
<el-form-item prop="username">
<el-input v-model="loginForm.username" prefix-icon="el-icon-user" placeholder="用户名" size="large"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="loginForm.password" prefix-icon="el-icon-lock" placeholder="密码" type="password" size="large" @keyup.enter.native="submitForm"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" class="login-button" @click="submitForm" :loading="loading" size="large">登录</el-button>
</el-form-item>
</el-form>
<div class="error-message" v-if="errorMessage">{{ errorMessage }}</div>
<div class="login-footer">
© 2025 ABOT | 智能机器人管理平台
</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data() {
return {
loginForm: {
username: '',
password: ''
},
rules: {
username: [
{ required: true, message: '请输入用户名', trigger: 'blur' }
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' }
]
},
loading: false,
errorMessage: ''
}
},
methods: {
submitForm() {
this.$refs.loginForm.validate((valid) => {
if (valid) {
this.loading = true;
// 创建表单数据
const formData = new FormData();
formData.append('username', this.loginForm.username);
formData.append('password', this.loginForm.password);
// 发送POST请求
fetch('/login', {
method: 'POST',
body: formData
})
.then(response => {
if (response.redirected) {
window.location.href = response.url;
} else {
return response.text();
}
})
.then(html => {
if (html) {
// 如果返回HTML,说明登录失败
this.errorMessage = '用户名或密码错误';
this.loading = false;
}
})
.catch(error => {
console.error('登录出错:', error);
this.errorMessage = '登录请求失败,请稍后重试';
this.loading = false;
});
}
});
}
}
});
</script>
</body>
</html>