优化登录界面
This commit is contained in:
@@ -1,70 +1,411 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from "element-plus";
|
||||||
import { reactive, ref } from 'vue'
|
import { ChatLineRound, Iphone } from "@element-plus/icons-vue";
|
||||||
|
import { onUnmounted, reactive, ref } from "vue";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
import { sendSmsCode } from '@/api/auth'
|
import { sendSmsCode } from "@/api/auth";
|
||||||
import { useSessionStore } from '@/stores/session'
|
import { useSessionStore } from "@/stores/session";
|
||||||
|
|
||||||
const session = useSessionStore()
|
const router = useRouter();
|
||||||
const loading = ref(false)
|
const session = useSessionStore();
|
||||||
const sending = ref(false)
|
const loading = ref(false);
|
||||||
|
const sending = ref(false);
|
||||||
|
const countDown = ref(0);
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
phone: '',
|
phone: "",
|
||||||
code: '',
|
code: "",
|
||||||
})
|
});
|
||||||
|
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null;
|
||||||
|
|
||||||
|
function startCountDown() {
|
||||||
|
countDown.value = 60;
|
||||||
|
timer = setInterval(() => {
|
||||||
|
countDown.value--;
|
||||||
|
if (countDown.value <= 0) {
|
||||||
|
clearInterval(timer!);
|
||||||
|
timer = null;
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer);
|
||||||
|
timer = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
async function handleSendCode() {
|
async function handleSendCode() {
|
||||||
sending.value = true
|
if (!form.phone.trim()) {
|
||||||
|
ElMessage.warning("请输入手机号");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sending.value = true;
|
||||||
try {
|
try {
|
||||||
await sendSmsCode(form.phone)
|
await sendSmsCode(form.phone);
|
||||||
ElMessage.success('验证码已生成,请查看后端日志')
|
ElMessage.success("验证码已生成,请查看后端日志");
|
||||||
|
startCountDown();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(readError(error, '验证码发送失败'))
|
ElMessage.error(readError(error, "验证码发送失败"));
|
||||||
} finally {
|
} finally {
|
||||||
sending.value = false
|
sending.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleLogin() {
|
async function handleLogin() {
|
||||||
loading.value = true
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
await session.login(form.phone, form.code)
|
await session.login(form.phone, form.code);
|
||||||
ElMessage.success('登录成功')
|
ElMessage.success("登录成功");
|
||||||
|
await router.push("/");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(readError(error, '登录失败'))
|
ElMessage.error(readError(error, "登录失败"));
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readError(error: unknown, fallback: string) {
|
function readError(error: unknown, fallback: string) {
|
||||||
if (typeof error === 'object' && error && 'response' in error) {
|
if (typeof error === "object" && error && "response" in error) {
|
||||||
const response = (error as { response?: { data?: { message?: string } } }).response
|
const response = (error as { response?: { data?: { message?: string } } })
|
||||||
return response?.data?.message || fallback
|
.response;
|
||||||
|
return response?.data?.message || fallback;
|
||||||
}
|
}
|
||||||
return fallback
|
return fallback;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="page">
|
<section class="login-shell">
|
||||||
<div class="page-header">
|
<div class="login-card">
|
||||||
<p class="eyebrow">SMS Login</p>
|
<div class="login-left">
|
||||||
<h1>手机号登录</h1>
|
<div class="brand-lockup">
|
||||||
<p>当前是开发态短信适配器,验证码会打印在后端日志里。</p>
|
<div class="brand-logo">锤</div>
|
||||||
|
<strong>大锤商行</strong>
|
||||||
|
</div>
|
||||||
|
<div class="login-hero">
|
||||||
|
<h2>安全租号<br />畅享游戏</h2>
|
||||||
|
<p>
|
||||||
|
高效、安全的哈夫币账号交易平台。<br />
|
||||||
|
7×24 小时智能订单系统随时为您服务。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="login-footer">
|
||||||
|
<span>© 哈夫币租号平台</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-form class="login-form" label-position="top">
|
<div class="login-right">
|
||||||
|
<div class="login-header">
|
||||||
|
<p class="eyebrow">SMS Login</p>
|
||||||
|
<h1>欢迎回来</h1>
|
||||||
|
<p class="subtitle">登录后即可发布或租赁账号</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-form class="user-form" label-position="top" @submit.prevent>
|
||||||
<el-form-item label="手机号">
|
<el-form-item label="手机号">
|
||||||
<el-input v-model="form.phone" maxlength="11" placeholder="请输入手机号" />
|
<el-input
|
||||||
|
v-model="form.phone"
|
||||||
|
maxlength="11"
|
||||||
|
placeholder="请输入手机号"
|
||||||
|
size="large"
|
||||||
|
:prefix-icon="Iphone"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="验证码">
|
<el-form-item label="验证码">
|
||||||
<div class="code-row">
|
<div class="user-code-row">
|
||||||
<el-input v-model="form.code" maxlength="6" placeholder="6 位验证码" />
|
<el-input
|
||||||
<el-button :loading="sending" @click="handleSendCode">发送</el-button>
|
v-model="form.code"
|
||||||
|
maxlength="6"
|
||||||
|
placeholder="6 位验证码"
|
||||||
|
size="large"
|
||||||
|
:prefix-icon="ChatLineRound"
|
||||||
|
@keyup.enter="handleLogin"
|
||||||
|
/>
|
||||||
|
<el-button
|
||||||
|
size="large"
|
||||||
|
:disabled="countDown > 0 || sending"
|
||||||
|
:loading="sending"
|
||||||
|
@click="handleSendCode"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
countDown > 0
|
||||||
|
? `${countDown}s`
|
||||||
|
: sending
|
||||||
|
? "发送中"
|
||||||
|
: "发送验证码"
|
||||||
|
}}
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-button type="primary" :loading="loading" @click="handleLogin">登录</el-button>
|
|
||||||
|
<el-button
|
||||||
|
class="user-login-btn"
|
||||||
|
type="primary"
|
||||||
|
size="large"
|
||||||
|
:loading="loading"
|
||||||
|
@click="handleLogin"
|
||||||
|
>
|
||||||
|
登录
|
||||||
|
</el-button>
|
||||||
|
|
||||||
|
<p class="login-notice">
|
||||||
|
当前为开发态短信适配器,验证码会打印在后端日志中
|
||||||
|
</p>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.login-shell {
|
||||||
|
display: grid;
|
||||||
|
flex: 1;
|
||||||
|
place-items: center;
|
||||||
|
margin: -20px -24px;
|
||||||
|
padding: 32px 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-card {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 420px;
|
||||||
|
width: min(940px, 100%);
|
||||||
|
min-height: 520px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.7);
|
||||||
|
border-radius: 20px;
|
||||||
|
background: rgba(255, 255, 255, 0.65);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
box-shadow: 0 24px 80px rgba(17, 24, 39, 0.08),
|
||||||
|
0 1px 0 rgba(255, 255, 255, 0.6) inset;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========== 左侧品牌区 ========== */
|
||||||
|
.login-left {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 40px 36px;
|
||||||
|
background: radial-gradient(
|
||||||
|
circle at 30% 20%,
|
||||||
|
rgba(20, 119, 255, 0.08),
|
||||||
|
transparent 50%
|
||||||
|
),
|
||||||
|
radial-gradient(
|
||||||
|
circle at 80% 90%,
|
||||||
|
rgba(109, 40, 217, 0.06),
|
||||||
|
transparent 50%
|
||||||
|
),
|
||||||
|
linear-gradient(160deg, rgba(20, 119, 255, 0.06), rgba(109, 40, 217, 0.03));
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-lockup {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-logo {
|
||||||
|
display: grid;
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
place-items: center;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: linear-gradient(135deg, #1477ff, #2f8dff);
|
||||||
|
box-shadow: 0 8px 24px rgba(20, 119, 255, 0.22);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-lockup strong {
|
||||||
|
color: #0f172a;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 800;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-hero h2 {
|
||||||
|
margin: 0 0 14px;
|
||||||
|
color: #0f172a;
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.25;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-hero p {
|
||||||
|
margin: 0;
|
||||||
|
color: #475569;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.7;
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-footer span {
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========== 右侧表单区 ========== */
|
||||||
|
.login-right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 36px 32px;
|
||||||
|
background: rgba(255, 255, 255, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-header {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-header .eyebrow {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
color: #1477ff;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-header h1 {
|
||||||
|
margin: 0;
|
||||||
|
color: #0f172a;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-header .subtitle {
|
||||||
|
margin: 8px 0 0;
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-form :deep(.el-form-item__label) {
|
||||||
|
color: #334155;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-form :deep(.el-input__wrapper) {
|
||||||
|
background: #ffffff;
|
||||||
|
box-shadow: 0 0 0 1px #e2e8f0 inset;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 0 12px;
|
||||||
|
transition: box-shadow 0.2s, background 0.2s;
|
||||||
|
}
|
||||||
|
.user-form :deep(.el-input__wrapper:hover) {
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
.user-form :deep(.el-input__wrapper.is-focus) {
|
||||||
|
background: #ffffff;
|
||||||
|
box-shadow: 0 0 0 1px rgba(20, 119, 255, 0.45) inset,
|
||||||
|
0 0 0 3px rgba(20, 119, 255, 0.08);
|
||||||
|
}
|
||||||
|
.user-form :deep(.el-input__inner) {
|
||||||
|
color: #0f172a;
|
||||||
|
font-size: 14px;
|
||||||
|
height: 44px;
|
||||||
|
}
|
||||||
|
.user-form :deep(.el-input__inner::placeholder) {
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
.user-form :deep(.el-input__prefix-inner) {
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-code-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 120px;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-code-row .el-button {
|
||||||
|
height: 46px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
|
background: #ffffff;
|
||||||
|
border-color: #1477ff;
|
||||||
|
color: #1477ff;
|
||||||
|
box-shadow: none;
|
||||||
|
transition: background 0.2s, color 0.2s;
|
||||||
|
}
|
||||||
|
.user-code-row .el-button:hover:not(:disabled) {
|
||||||
|
background: #1477ff;
|
||||||
|
border-color: #1477ff;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.user-code-row .el-button:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-login-btn {
|
||||||
|
width: 100%;
|
||||||
|
height: 46px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-top: 8px;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
background: linear-gradient(135deg, #1477ff, #2f8dff);
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 10px 28px rgba(20, 119, 255, 0.22);
|
||||||
|
transition: transform 0.15s, box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
.user-login-btn:hover {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 14px 36px rgba(20, 119, 255, 0.28);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-notice {
|
||||||
|
margin: 18px 0 0;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========== 响应式 ========== */
|
||||||
|
@media (max-width: 860px) {
|
||||||
|
.login-card {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
max-width: 420px;
|
||||||
|
}
|
||||||
|
.login-left {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.login-right {
|
||||||
|
padding: 32px 28px;
|
||||||
|
}
|
||||||
|
.login-shell {
|
||||||
|
padding: 24px 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.login-shell {
|
||||||
|
padding: 16px 12px;
|
||||||
|
}
|
||||||
|
.login-right {
|
||||||
|
padding: 24px 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.user-login-btn {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,91 +1,434 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from "element-plus";
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { Lock, User } from "@element-plus/icons-vue";
|
||||||
import { useRouter } from 'vue-router'
|
import { onMounted, reactive, ref } from "vue";
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
import { fetchAdminCaptcha, type AdminCaptcha } from '@/api/adminAuth'
|
import { fetchAdminCaptcha, type AdminCaptcha } from "@/api/adminAuth";
|
||||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
import { useAdminSessionStore } from "@/stores/adminSession";
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter();
|
||||||
const adminSession = useAdminSessionStore()
|
const adminSession = useAdminSessionStore();
|
||||||
const loading = ref(false)
|
const loading = ref(false);
|
||||||
const captchaLoading = ref(false)
|
const captchaLoading = ref(false);
|
||||||
const captcha = ref<AdminCaptcha | null>(null)
|
const captcha = ref<AdminCaptcha | null>(null);
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
username: 'admin',
|
username: "admin",
|
||||||
password: 'admin123456',
|
password: "admin123456",
|
||||||
captchaCode: '',
|
captchaCode: "",
|
||||||
})
|
});
|
||||||
|
|
||||||
onMounted(loadCaptcha)
|
onMounted(loadCaptcha);
|
||||||
|
|
||||||
async function loadCaptcha() {
|
async function loadCaptcha() {
|
||||||
captchaLoading.value = true
|
captchaLoading.value = true;
|
||||||
try {
|
try {
|
||||||
captcha.value = await fetchAdminCaptcha()
|
captcha.value = await fetchAdminCaptcha();
|
||||||
form.captchaCode = ''
|
form.captchaCode = "";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(readError(error, '验证码加载失败'))
|
ElMessage.error(readError(error, "验证码加载失败"));
|
||||||
} finally {
|
} finally {
|
||||||
captchaLoading.value = false
|
captchaLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleLogin() {
|
async function handleLogin() {
|
||||||
loading.value = true
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
await adminSession.login(form.username, form.password, captcha.value?.captcha_id || '', form.captchaCode)
|
await adminSession.login(
|
||||||
ElMessage.success('后台登录成功')
|
form.username,
|
||||||
await router.push('/admin/dashboard')
|
form.password,
|
||||||
|
captcha.value?.captcha_id || "",
|
||||||
|
form.captchaCode
|
||||||
|
);
|
||||||
|
ElMessage.success("后台登录成功");
|
||||||
|
await router.push("/admin/dashboard");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(readError(error, '后台登录失败'))
|
ElMessage.error(readError(error, "后台登录失败"));
|
||||||
await loadCaptcha()
|
await loadCaptcha();
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readError(error: unknown, fallback: string) {
|
function readError(error: unknown, fallback: string) {
|
||||||
if (typeof error === 'object' && error && 'response' in error) {
|
if (typeof error === "object" && error && "response" in error) {
|
||||||
const response = (error as { response?: { data?: { message?: string } } }).response
|
const response = (error as { response?: { data?: { message?: string } } })
|
||||||
return response?.data?.message || fallback
|
.response;
|
||||||
|
return response?.data?.message || fallback;
|
||||||
}
|
}
|
||||||
return fallback
|
return fallback;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="admin-login-shell">
|
<section class="admin-login-shell">
|
||||||
<div class="admin-login-panel">
|
<div class="admin-login-glow" aria-hidden="true" />
|
||||||
<RouterLink class="admin-login-brand" to="/">
|
<div class="admin-login-glow secondary" aria-hidden="true" />
|
||||||
<span class="brand-mark">H</span>
|
|
||||||
<span>哈夫币后台</span>
|
|
||||||
</RouterLink>
|
|
||||||
|
|
||||||
<div class="admin-login-header">
|
<div class="admin-login-card">
|
||||||
<p class="eyebrow">Admin Login</p>
|
<div class="admin-login-left">
|
||||||
<h1>后台登录</h1>
|
<div class="brand-lockup">
|
||||||
<p>管理员登录后进入后台管理系统。</p>
|
<div class="brand-logo">H</div>
|
||||||
|
<strong>大锤商行 - 后台管理</strong>
|
||||||
|
</div>
|
||||||
|
<div class="admin-login-hero">
|
||||||
|
<h2>高效管理<br />从容掌控</h2>
|
||||||
|
<p>统一的后台管理系统,助您轻松处理订单、用户与运营数据。</p>
|
||||||
|
</div>
|
||||||
|
<div class="admin-login-footer">
|
||||||
|
<span>© 哈夫币租号平台</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-form label-position="top">
|
<div class="admin-login-right">
|
||||||
|
<div class="admin-login-header">
|
||||||
|
<p class="eyebrow">Admin Login</p>
|
||||||
|
<h1>管理员登录</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-form class="admin-form" label-position="top" @submit.prevent>
|
||||||
<el-form-item label="用户名">
|
<el-form-item label="用户名">
|
||||||
<el-input v-model="form.username" placeholder="请输入管理员用户名" />
|
<el-input
|
||||||
|
v-model="form.username"
|
||||||
|
placeholder="请输入管理员用户名"
|
||||||
|
size="large"
|
||||||
|
:prefix-icon="User"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="密码">
|
<el-form-item label="密码">
|
||||||
<el-input v-model="form.password" type="password" show-password placeholder="请输入管理员密码" @keyup.enter="handleLogin" />
|
<el-input
|
||||||
|
v-model="form.password"
|
||||||
|
type="password"
|
||||||
|
show-password
|
||||||
|
placeholder="请输入管理员密码"
|
||||||
|
size="large"
|
||||||
|
:prefix-icon="Lock"
|
||||||
|
@keyup.enter="handleLogin"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="验证码">
|
<el-form-item label="验证码">
|
||||||
<div class="admin-captcha-row">
|
<div class="admin-captcha-row">
|
||||||
<el-input v-model="form.captchaCode" maxlength="4" placeholder="请输入验证码" @keyup.enter="handleLogin" />
|
<el-input
|
||||||
<button class="captcha-image-button" type="button" :disabled="captchaLoading" @click="loadCaptcha">
|
v-model="form.captchaCode"
|
||||||
|
maxlength="4"
|
||||||
|
placeholder="请输入验证码"
|
||||||
|
size="large"
|
||||||
|
@keyup.enter="handleLogin"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
class="captcha-image-button"
|
||||||
|
type="button"
|
||||||
|
:disabled="captchaLoading"
|
||||||
|
@click="loadCaptcha"
|
||||||
|
>
|
||||||
<img v-if="captcha" :src="captcha.image" alt="验证码" />
|
<img v-if="captcha" :src="captcha.image" alt="验证码" />
|
||||||
<span v-else>刷新</span>
|
<span v-else>刷新</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-button class="full-control" type="primary" :loading="loading" @click="handleLogin">登录后台</el-button>
|
<el-button
|
||||||
|
class="admin-login-btn"
|
||||||
|
type="primary"
|
||||||
|
size="large"
|
||||||
|
:loading="loading"
|
||||||
|
@click="handleLogin"
|
||||||
|
>
|
||||||
|
登录后台
|
||||||
|
</el-button>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
<RouterLink class="back-home" to="/">← 返回首页</RouterLink>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.admin-login-shell {
|
||||||
|
position: relative;
|
||||||
|
display: grid;
|
||||||
|
min-height: 100vh;
|
||||||
|
place-items: center;
|
||||||
|
overflow: hidden;
|
||||||
|
background: radial-gradient(
|
||||||
|
circle at 18% 20%,
|
||||||
|
rgba(20, 119, 255, 0.14),
|
||||||
|
transparent 42%
|
||||||
|
),
|
||||||
|
radial-gradient(
|
||||||
|
circle at 82% 80%,
|
||||||
|
rgba(109, 40, 217, 0.12),
|
||||||
|
transparent 42%
|
||||||
|
),
|
||||||
|
linear-gradient(180deg, #0b1120 0%, #0f172a 60%, #111827 100%);
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-glow {
|
||||||
|
position: absolute;
|
||||||
|
top: -10%;
|
||||||
|
left: -10%;
|
||||||
|
width: 50vw;
|
||||||
|
height: 50vw;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: radial-gradient(
|
||||||
|
circle,
|
||||||
|
rgba(20, 119, 255, 0.22),
|
||||||
|
transparent 65%
|
||||||
|
);
|
||||||
|
filter: blur(80px);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.admin-login-glow.secondary {
|
||||||
|
top: auto;
|
||||||
|
left: auto;
|
||||||
|
right: -10%;
|
||||||
|
bottom: -10%;
|
||||||
|
background: radial-gradient(
|
||||||
|
circle,
|
||||||
|
rgba(109, 40, 217, 0.18),
|
||||||
|
transparent 65%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-card {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 420px;
|
||||||
|
width: min(960px, 100%);
|
||||||
|
min-height: 560px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||||
|
border-radius: 20px;
|
||||||
|
background: rgba(15, 23, 42, 0.55);
|
||||||
|
backdrop-filter: blur(24px);
|
||||||
|
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35),
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========== 左侧品牌区 ========== */
|
||||||
|
.admin-login-left {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 40px 36px;
|
||||||
|
background: radial-gradient(
|
||||||
|
circle at 30% 20%,
|
||||||
|
rgba(20, 119, 255, 0.12),
|
||||||
|
transparent 50%
|
||||||
|
),
|
||||||
|
radial-gradient(circle at 80% 90%, rgba(109, 40, 217, 0.1), transparent 50%),
|
||||||
|
linear-gradient(160deg, rgba(20, 119, 255, 0.1), rgba(109, 40, 217, 0.06));
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-lockup {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-logo {
|
||||||
|
display: grid;
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
place-items: center;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: linear-gradient(135deg, #1477ff, #2f8dff);
|
||||||
|
box-shadow: 0 8px 24px rgba(20, 119, 255, 0.25);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-lockup strong {
|
||||||
|
color: #f8fafc;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 800;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-hero h2 {
|
||||||
|
margin: 0 0 14px;
|
||||||
|
color: #f1f5f9;
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.25;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-hero p {
|
||||||
|
margin: 0;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.7;
|
||||||
|
max-width: 320px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-footer span {
|
||||||
|
color: #475569;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========== 右侧表单区 ========== */
|
||||||
|
.admin-login-right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 36px 32px;
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-header {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-header .eyebrow {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
color: #1477ff;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-header h1 {
|
||||||
|
margin: 0;
|
||||||
|
color: #f8fafc;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form :deep(.el-form-item__label) {
|
||||||
|
color: #cbd5e1;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-form :deep(.el-input__wrapper) {
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 0 12px;
|
||||||
|
transition: box-shadow 0.2s, background 0.2s;
|
||||||
|
}
|
||||||
|
.admin-form :deep(.el-input__wrapper:hover) {
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
}
|
||||||
|
.admin-form :deep(.el-input__wrapper.is-focus) {
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
box-shadow: 0 0 0 1px rgba(20, 119, 255, 0.45) inset,
|
||||||
|
0 0 0 3px rgba(20, 119, 255, 0.08);
|
||||||
|
}
|
||||||
|
.admin-form :deep(.el-input__inner) {
|
||||||
|
color: #f1f5f9;
|
||||||
|
font-size: 14px;
|
||||||
|
height: 44px;
|
||||||
|
}
|
||||||
|
.admin-form :deep(.el-input__inner::placeholder) {
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
.admin-form :deep(.el-input__prefix-inner) {
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-captcha-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 132px;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.captcha-image-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 44px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
border-radius: 10px;
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
padding: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: background 0.2s, border-color 0.2s;
|
||||||
|
}
|
||||||
|
.captcha-image-button:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.07);
|
||||||
|
border-color: rgba(255, 255, 255, 0.14);
|
||||||
|
}
|
||||||
|
.captcha-image-button:disabled {
|
||||||
|
cursor: wait;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
.captcha-image-button img {
|
||||||
|
display: block;
|
||||||
|
width: 132px;
|
||||||
|
height: 44px;
|
||||||
|
}
|
||||||
|
.captcha-image-button span {
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-login-btn {
|
||||||
|
width: 100%;
|
||||||
|
height: 46px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-top: 8px;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
background: linear-gradient(135deg, #1477ff, #2f8dff);
|
||||||
|
border: none;
|
||||||
|
box-shadow: 0 10px 28px rgba(20, 119, 255, 0.25);
|
||||||
|
transition: transform 0.15s, box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
.admin-login-btn:hover {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 14px 36px rgba(20, 119, 255, 0.32);
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-home {
|
||||||
|
display: block;
|
||||||
|
margin-top: 18px;
|
||||||
|
text-align: center;
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 13px;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
.back-home:hover {
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ========== 响应式 ========== */
|
||||||
|
@media (max-width: 860px) {
|
||||||
|
.admin-login-card {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
max-width: 420px;
|
||||||
|
}
|
||||||
|
.admin-login-left {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.admin-login-right {
|
||||||
|
padding: 32px 28px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.admin-login-shell {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.admin-login-right {
|
||||||
|
padding: 24px 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.admin-login-btn {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user