26-7-31-1
This commit is contained in:
@@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<div class="login-wrapper">
|
||||
<div class="login-bg" />
|
||||
<div class="login-mask" />
|
||||
<el-card class="login-card" shadow="always">
|
||||
<div class="header">
|
||||
<div class="logo">
|
||||
<el-icon :size="28"><OfficeBuilding /></el-icon>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="title">智慧医院管理系统</h2>
|
||||
<p class="subtitle">患者 · 影像 · 病历 · 预约一体化管理</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-form ref="formRef" :model="form" :rules="rules" size="large" @submit.prevent="onSubmit">
|
||||
<el-form-item prop="username">
|
||||
<el-input v-model="form.username" placeholder="用户名" clearable>
|
||||
<template #prefix><el-icon><User /></el-icon></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-input
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
placeholder="密码"
|
||||
show-password
|
||||
@keyup.enter="onSubmit"
|
||||
>
|
||||
<template #prefix><el-icon><Lock /></el-icon></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-button type="primary" class="submit" :loading="loading" @click="onSubmit">
|
||||
登 录
|
||||
</el-button>
|
||||
</el-form>
|
||||
|
||||
<div class="accounts">
|
||||
<div class="accounts-title">测试账号</div>
|
||||
<div class="account-row">
|
||||
<el-tag type="danger" effect="plain">管理员</el-tag>
|
||||
<code>admin / admin123</code>
|
||||
<el-button link type="primary" @click="fill('admin', 'admin123')">填入</el-button>
|
||||
</div>
|
||||
<div class="account-row">
|
||||
<el-tag type="success" effect="plain">医生</el-tag>
|
||||
<code>doctor1 / pass123</code>
|
||||
<el-button link type="primary" @click="fill('doctor1', 'pass123')">填入</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { User, Lock, OfficeBuilding } from '@element-plus/icons-vue'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const formRef = ref()
|
||||
const loading = ref(false)
|
||||
const form = reactive({ username: '', password: '' })
|
||||
const rules = {
|
||||
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const fill = (u, p) => {
|
||||
form.username = u
|
||||
form.password = p
|
||||
}
|
||||
|
||||
const onSubmit = async () => {
|
||||
await formRef.value.validate()
|
||||
loading.value = true
|
||||
try {
|
||||
await userStore.login(form)
|
||||
ElMessage.success(`欢迎回来,${userStore.displayName}`)
|
||||
const redirect = route.query.redirect || '/dashboard'
|
||||
await router.replace(String(redirect))
|
||||
} catch {
|
||||
/* 拦截器已提示 */
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-wrapper {
|
||||
position: relative;
|
||||
min-height: 100vh;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.login-bg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: url('/images/login-bg.jpg') center / cover no-repeat;
|
||||
transform: scale(1.02);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.login-mask {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background:
|
||||
linear-gradient(120deg, rgba(15, 61, 102, 0.72) 0%, rgba(30, 96, 145, 0.55) 45%, rgba(56, 189, 248, 0.35) 100%);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 440px;
|
||||
max-width: 100%;
|
||||
border-radius: 18px;
|
||||
border: none;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
background: rgba(255, 255, 255, 0.94);
|
||||
backdrop-filter: blur(10px);
|
||||
box-shadow: 0 20px 50px rgba(15, 61, 102, 0.35);
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.logo {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg, #1e6091, #38bdf8);
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
color: #0f172a;
|
||||
}
|
||||
.subtitle {
|
||||
margin: 6px 0 0;
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
}
|
||||
.submit {
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
font-size: 15px;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
.accounts {
|
||||
margin-top: 20px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px dashed #e2e8f0;
|
||||
}
|
||||
.accounts-title {
|
||||
font-size: 12px;
|
||||
color: #94a3b8;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.account-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.account-row code {
|
||||
flex: 1;
|
||||
background: #f8fafc;
|
||||
padding: 4px 8px;
|
||||
border-radius: 6px;
|
||||
color: #334155;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user