Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | 1x 1x 3x 2x 1x 3x 2x 2x 1x 1x 1x 1x | <template>
<div class="auth-wrapper">
<a-card :bordered="false" class="auth-card">
<div class="auth-header">
<div class="auth-title">登录</div>
<div class="auth-subtitle">欢迎回来,请登录您的账户</div>
</div>
<a-alert
v-if="authStore.error"
:message="authStore.error"
type="error"
show-icon
closable
style="margin-bottom: 24px"
@close="authStore.error = null"
/>
<a-form
layout="vertical"
:model="formState"
@finish="onFinish"
hide-required-mark
class="auth-form"
>
<a-form-item
name="username"
:rules="[{ required: true, message: '请输入用户名' }]"
>
<a-input
v-model:value="formState.username"
size="large"
placeholder="用户名"
>
<template #prefix>
<user-outlined style="color: rgba(0,0,0,.25)" />
</template>
</a-input>
</a-form-item>
<a-form-item
name="password"
:rules="[{ required: true, message: '请输入密码' }]"
>
<a-input-password
v-model:value="formState.password"
size="large"
placeholder="密码"
>
<template #prefix>
<lock-outlined style="color: rgba(0,0,0,.25)" />
</template>
</a-input-password>
</a-form-item>
<a-form-item>
<a-button
type="primary"
html-type="submit"
size="large"
block
:loading="authStore.loading"
class="submit-btn"
>
登录
</a-button>
</a-form-item>
<div class="auth-footer">
<span>还没有账号?</span>
<router-link to="/auth/register" class="link-btn">立即注册</router-link>
</div>
</a-form>
</a-card>
</div>
</template>
<script setup lang="ts">
import { reactive } from 'vue'
import { useAuthStore } from '@/stores/auth'
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
const authStore = useAuthStore()
const formState = reactive({
username: '',
password: ''
})
const onFinish = async (values: any) => {
await authStore.login(values)
}
</script>
<style scoped>
.auth-wrapper {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.auth-card {
width: 100%;
max-width: 400px;
background: #fff;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
padding: 24px;
}
.auth-header {
text-align: center;
margin-bottom: 32px;
}
.auth-title {
font-size: 24px;
color: rgba(0, 0, 0, 0.85);
font-weight: 600;
margin-bottom: 8px;
}
.auth-subtitle {
font-size: 14px;
color: rgba(0, 0, 0, 0.45);
}
.auth-form {
margin-bottom: 0;
}
.submit-btn {
height: 40px;
font-size: 16px;
margin-top: 8px;
}
.auth-footer {
text-align: center;
font-size: 14px;
margin-top: 16px;
color: rgba(0, 0, 0, 0.45);
}
.link-btn {
color: #1890ff;
font-weight: 500;
margin-left: 4px;
}
.link-btn:hover {
text-decoration: underline;
}
@media (max-width: 576px) {
.auth-card {
box-shadow: none;
padding: 0;
background: transparent;
}
}
</style>
|