This commit is contained in:
BianLzhaoMin 2025-11-26 17:50:10 +08:00
parent 88c29b9dae
commit 3a2f0a0417
3 changed files with 425 additions and 362 deletions

View File

@ -307,7 +307,7 @@ export default {
border-radius: 10px; border-radius: 10px;
align-content: flex-start; align-content: flex-start;
justify-items: center; justify-items: center;
height: 47%; height: 62%;
} }
.card-image { .card-image {

View File

@ -78,7 +78,7 @@
</div> </div>
<div class="person-info"> <div class="person-info">
<span class="name">备注:{{ item.remark }}</span> <span class="name">{{ item.remark }}</span>
</div> </div>
<!-- <div class="tags"> <!-- <div class="tags">
<div class="tag-row"> <div class="tag-row">
@ -283,7 +283,7 @@ export default {
border-radius: 10px; border-radius: 10px;
align-content: flex-start; align-content: flex-start;
justify-items: center; justify-items: center;
height: 43%; height: 56%;
} }
.card-image { .card-image {

View File

@ -1,421 +1,484 @@
<template> <template>
<div class="login"> <div class="login">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form"> <el-form
<h3 class="title">欢迎登录</h3> ref="loginForm"
<h3 class="title">{{title}}</h3> :model="loginForm"
<el-form-item prop="username"> :rules="loginRules"
<el-input class="login-form"
v-model="loginForm.username"
type="text"
auto-complete="off"
placeholder="账号"
> >
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> <h3 class="title">欢迎登录</h3>
</el-input> <h3 class="title">{{ title }}</h3>
</el-form-item> <el-form-item prop="username">
<el-form-item prop="password"> <el-input
<el-input v-model="loginForm.username"
v-model="loginForm.password" type="text"
type="password" auto-complete="off"
auto-complete="off" placeholder="账号"
placeholder="密码" >
@keyup.enter.native="handleLogin" <svg-icon
> slot="prefix"
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" /> icon-class="user"
</el-input> class="el-input__icon input-icon"
</el-form-item> />
<el-form-item prop="code" v-if="captchaEnabled"> </el-input>
<div class="code-wrapper"> </el-form-item>
<el-input <el-form-item prop="password">
v-model="loginForm.code" <el-input
auto-complete="off" v-model="loginForm.password"
placeholder="验证码" type="password"
@keyup.enter.native="handleLogin" auto-complete="off"
> placeholder="密码"
<svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" /> show-password
</el-input> @keyup.enter.native="handleLogin"
<div class="login-code"> >
<img :src="codeUrl" @click="getCode" class="login-code-img"/> <svg-icon
</div> slot="prefix"
icon-class="password"
class="el-input__icon input-icon"
/>
</el-input>
</el-form-item>
<el-form-item prop="code" v-if="captchaEnabled">
<div class="code-wrapper">
<el-input
v-model="loginForm.code"
auto-complete="off"
placeholder="验证码"
@keyup.enter.native="handleLogin"
>
<svg-icon
slot="prefix"
icon-class="validCode"
class="el-input__icon input-icon"
/>
</el-input>
<div class="login-code">
<img
:src="codeUrl"
@click="getCode"
class="login-code-img"
/>
</div>
</div>
</el-form-item>
<el-checkbox
v-model="loginForm.rememberMe"
style="margin: 0px 0px 25px 0px"
>记住密码</el-checkbox
>
<el-form-item style="width: 100%">
<el-button
:loading="loading"
size="medium"
type="primary"
style="width: 100%"
@click.native.prevent="handleLogin"
>
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
<div style="float: right" v-if="register">
<router-link class="link-type" :to="'/register'"
>立即注册</router-link
>
</div>
</el-form-item>
</el-form>
<!-- 底部 -->
<div class="el-login-footer">
<span>© 2025 智慧图档管理系统. All rights reserved.</span>
</div> </div>
</el-form-item>
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
<el-form-item style="width:100%;">
<el-button
:loading="loading"
size="medium"
type="primary"
style="width:100%;"
@click.native.prevent="handleLogin"
>
<span v-if="!loading"> </span>
<span v-else> 中...</span>
</el-button>
<div style="float: right;" v-if="register">
<router-link class="link-type" :to="'/register'">立即注册</router-link>
</div>
</el-form-item>
</el-form>
<!-- 底部 -->
<div class="el-login-footer">
<span>© 2025 智慧图档管理系统. All rights reserved.</span>
</div> </div>
</div>
</template> </template>
<script> <script>
import { getCodeImg } from "@/api/login" import { getCodeImg } from '@/api/login'
import Cookies from "js-cookie" import Cookies from 'js-cookie'
import { encrypt, decrypt } from '@/utils/jsencrypt' import { encrypt, decrypt } from '@/utils/jsencrypt'
import { getSystemConfigApi } from '@/utils/systemConfig' import { getSystemConfigApi } from '@/utils/systemConfig'
export default { export default {
name: "Login", name: 'Login',
data() { data() {
return { return {
title: process.env.VUE_APP_TITLE, title: process.env.VUE_APP_TITLE,
codeUrl: "", codeUrl: '',
loginForm: { loginForm: {
username: "", username: '',
password: "", password: '',
rememberMe: false, rememberMe: false,
code: "", code: '',
uuid: "" uuid: '',
}, },
loginRules: { loginRules: {
username: [ username: [
{ required: true, trigger: "blur", message: "请输入您的账号" } {
], required: true,
password: [ trigger: 'blur',
{ required: true, trigger: "blur", message: "请输入您的密码" } message: '请输入您的账号',
], },
code: [{ required: true, trigger: "change", message: "请输入验证码" }] ],
}, password: [
loading: false, {
// required: true,
captchaEnabled: true, trigger: 'blur',
// message: '请输入您的密码',
register: false, },
redirect: undefined ],
} code: [
}, {
watch: { required: true,
$route: { trigger: 'change',
handler: function(route) { message: '请输入验证码',
this.redirect = route.query && route.query.redirect },
}, ],
immediate: true },
} loading: false,
}, //
created() { captchaEnabled: true,
this.getSystemConfig() //
this.getCode() register: false,
this.getCookie() redirect: undefined,
},
methods: {
async getSystemConfig(){
await getSystemConfigApi();
},
async getCode() {
await getCodeImg().then(res => {
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
if (this.captchaEnabled) {
this.codeUrl = "data:image/gif;base64," + res.img
this.loginForm.uuid = res.uuid
} }
})
}, },
getCookie() { watch: {
const username = Cookies.get("username") $route: {
const password = Cookies.get("password") handler: function (route) {
const rememberMe = Cookies.get('rememberMe') this.redirect = route.query && route.query.redirect
this.loginForm = { },
username: username === undefined ? this.loginForm.username : username, immediate: true,
password: password === undefined ? this.loginForm.password : decrypt(password), },
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
}
}, },
handleLogin() { created() {
this.$refs.loginForm.validate(valid => { this.getSystemConfig()
if (valid) { this.getCode()
this.loading = true this.getCookie()
if (this.loginForm.rememberMe) { },
Cookies.set("username", this.loginForm.username, { expires: 30 }) methods: {
Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 }) async getSystemConfig() {
Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 }) await getSystemConfigApi()
} else { },
Cookies.remove("username") async getCode() {
Cookies.remove("password") await getCodeImg().then((res) => {
Cookies.remove('rememberMe') this.captchaEnabled =
} res.captchaEnabled === undefined ? true : res.captchaEnabled
this.$store.dispatch("Login", this.loginForm).then(() => { if (this.captchaEnabled) {
this.$router.push({ path: this.redirect || "/" }).catch(()=>{}) this.codeUrl = 'data:image/gif;base64,' + res.img
}).catch(() => { this.loginForm.uuid = res.uuid
this.loading = false }
if (this.captchaEnabled) { })
this.getCode() },
getCookie() {
const username = Cookies.get('username')
const password = Cookies.get('password')
const rememberMe = Cookies.get('rememberMe')
this.loginForm = {
username:
username === undefined ? this.loginForm.username : username,
password:
password === undefined
? this.loginForm.password
: decrypt(password),
rememberMe:
rememberMe === undefined ? false : Boolean(rememberMe),
} }
}) },
} handleLogin() {
}) this.$refs.loginForm.validate((valid) => {
} if (valid) {
} this.loading = true
if (this.loginForm.rememberMe) {
Cookies.set('username', this.loginForm.username, {
expires: 30,
})
Cookies.set(
'password',
encrypt(this.loginForm.password),
{ expires: 30 },
)
Cookies.set('rememberMe', this.loginForm.rememberMe, {
expires: 30,
})
} else {
Cookies.remove('username')
Cookies.remove('password')
Cookies.remove('rememberMe')
}
this.$store
.dispatch('Login', this.loginForm)
.then(() => {
this.$router
.push({ path: this.redirect || '/' })
.catch(() => {})
})
.catch(() => {
this.loading = false
if (this.captchaEnabled) {
this.getCode()
}
})
}
})
},
},
} }
</script> </script>
<style rel="stylesheet/scss" lang="scss"> <style rel="stylesheet/scss" lang="scss">
.login { .login {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 100%; height: 100%;
background: #fff; background: #fff;
background-image: url("../assets/images/login-background.jpg"); background-image: url('../assets/images/login-background.jpg');
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: left center; background-position: left center;
background-size: contain; background-size: contain;
position: relative; position: relative;
&::before { &::before {
content: ''; content: '';
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
// background: linear-gradient(135deg, rgba(0, 110, 107, 0.1) 0%, rgba(0, 110, 107, 0.05) 100%); // background: linear-gradient(135deg, rgba(0, 110, 107, 0.1) 0%, rgba(0, 110, 107, 0.05) 100%);
z-index: 0; z-index: 0;
} }
} }
.title { .title {
margin: 0px auto 20px auto; margin: 0px auto 20px auto;
font-weight: bold; font-weight: bold;
text-align: left; text-align: left;
color: #060F2E; color: #060f2e;
font-size: 28px; font-size: 28px;
text-shadow: 0 2px 4px rgba(0,0,0,0.1); text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
position: relative; position: relative;
z-index: 1; z-index: 1;
} }
.login-form { .login-form {
border-radius: 12px; border-radius: 12px;
background: #ffffff; background: #ffffff;
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
width: 600px; width: 600px;
padding: 40px 30px 30px 30px; padding: 40px 30px 30px 30px;
z-index: 1; z-index: 1;
margin-left: 58%; margin-left: 58%;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15); box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
border: 1px solid rgba(0, 110, 107, 0.1); border: 1px solid rgba(0, 110, 107, 0.1);
position: relative;
&::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4px;
background: linear-gradient(90deg, #006E6B 0%, #008B8B 100%);
border-radius: 12px 12px 0 0;
}
.el-input {
height: 42px;
margin: 8px 0;
position: relative; position: relative;
.el-input__inner { &::before {
height: 42px; content: '';
border-radius: 8px; position: absolute;
border: 2px solid #e1e5e9; top: 0;
padding-left: 40px; left: 0;
font-size: 14px; right: 0;
transition: all 0.3s ease; height: 4px;
background: #ffffff; background: linear-gradient(90deg, #006e6b 0%, #008b8b 100%);
border-radius: 12px 12px 0 0;
&:focus {
border-color: #006E6B;
box-shadow: 0 0 0 3px rgba(0, 110, 107, 0.1);
background: #ffffff;
}
&:hover {
border-color: #008B8B;
}
} }
.el-input__prefix { .el-input {
position: absolute; height: 42px;
left: 12px; margin: 8px 0;
top: 50%; position: relative;
transform: translateY(-50%);
z-index: 1; .el-input__inner {
height: 42px;
border-radius: 8px;
border: 2px solid #e1e5e9;
padding-left: 40px;
font-size: 14px;
transition: all 0.3s ease;
background: #ffffff;
&:focus {
border-color: #006e6b;
box-shadow: 0 0 0 3px rgba(0, 110, 107, 0.1);
background: #ffffff;
}
&:hover {
border-color: #008b8b;
}
}
.el-input__prefix {
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
z-index: 1;
}
} }
}
.input-icon {
.input-icon { height: 16px;
height: 16px; width: 16px;
width: 16px; margin-left: 0;
margin-left: 0; color: #999;
color: #999; transition: color 0.3s ease;
transition: color 0.3s ease; position: absolute;
position: absolute; top: 50%;
top: 50%; left: 12px;
left: 12px; transform: translateY(-50%);
transform: translateY(-50%);
}
.el-form-item {
margin-bottom: 20px;
}
.el-checkbox {
margin-bottom: 20px;
.el-checkbox__label {
color: #666;
font-size: 14px;
} }
.el-checkbox__input.is-checked .el-checkbox__inner { .el-form-item {
background-color: #006E6B; margin-bottom: 20px;
border-color: #006E6B;
} }
}
.el-checkbox {
.el-button { margin-bottom: 20px;
height: 42px;
border-radius: 8px; .el-checkbox__label {
font-size: 16px; color: #666;
font-weight: 600; font-size: 14px;
background: linear-gradient(135deg, #006E6B 0%, #008B8B 100%); }
border: none;
transition: transform 0.2s ease, box-shadow 0.2s ease; .el-checkbox__input.is-checked .el-checkbox__inner {
will-change: transform; background-color: #006e6b;
border-color: #006e6b;
&:hover { }
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 110, 107, 0.25);
} }
&:active { .el-button {
transform: translateY(0); height: 42px;
box-shadow: 0 2px 6px rgba(0, 110, 107, 0.2); border-radius: 8px;
font-size: 16px;
font-weight: 600;
background: linear-gradient(135deg, #006e6b 0%, #008b8b 100%);
border: none;
transition: transform 0.2s ease, box-shadow 0.2s ease;
will-change: transform;
&:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 110, 107, 0.25);
}
&:active {
transform: translateY(0);
box-shadow: 0 2px 6px rgba(0, 110, 107, 0.2);
}
} }
}
.link-type {
.link-type { color: #006e6b;
color: #006E6B; text-decoration: none;
text-decoration: none; font-size: 14px;
font-size: 14px; transition: color 0.3s ease;
transition: color 0.3s ease;
&:hover {
&:hover { color: #008b8b;
color: #008B8B; text-decoration: underline;
text-decoration: underline; }
} }
}
} }
.login-tip { .login-tip {
font-size: 13px; font-size: 13px;
text-align: center; text-align: center;
color: #bfbfbf; color: #bfbfbf;
} }
.code-wrapper { .code-wrapper {
display: flex; display: flex;
gap: 10px; gap: 10px;
align-items: center; align-items: center;
.el-input { .el-input {
flex: 1; flex: 1;
} }
} }
.login-code { .login-code {
width: 120px; width: 120px;
height: 42px; height: 42px;
border-radius: 8px; border-radius: 8px;
overflow: hidden; overflow: hidden;
border: 2px solid #e1e5e9; border: 2px solid #e1e5e9;
cursor: pointer;
transition: all 0.3s ease;
flex-shrink: 0;
&:hover {
border-color: #006E6B;
transform: scale(1.02);
}
img {
cursor: pointer; cursor: pointer;
vertical-align: middle; transition: all 0.3s ease;
width: 100%; flex-shrink: 0;
height: 100%;
object-fit: cover; &:hover {
} border-color: #006e6b;
transform: scale(1.02);
}
img {
cursor: pointer;
vertical-align: middle;
width: 100%;
height: 100%;
object-fit: cover;
}
} }
.el-login-footer { .el-login-footer {
height: 60px; height: 60px;
line-height: 60px; line-height: 60px;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
width: 100%; width: 100%;
text-align: center; text-align: center;
color: rgba(255, 255, 255, 0.9); color: rgba(255, 255, 255, 0.9);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
font-size: 14px; 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica,
font-weight: 400; Arial, sans-serif;
letter-spacing: 0.5px; font-size: 14px;
background: rgba(0, 110, 107, 0.1); font-weight: 400;
backdrop-filter: blur(10px); letter-spacing: 0.5px;
z-index: 1; background: rgba(0, 110, 107, 0.1);
border-top: 1px solid rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px);
z-index: 1;
border-top: 1px solid rgba(255, 255, 255, 0.1);
} }
.login-code-img { .login-code-img {
height: 42px; height: 42px;
} }
// //
@media (max-width: 1200px) { @media (max-width: 1200px) {
.login-form { .login-form {
margin-left: 50%; margin-left: 50%;
width: 500px; width: 500px;
} }
} }
@media (max-width: 768px) { @media (max-width: 768px) {
.login { .login {
background-position: center; background-position: center;
} }
.login-form { .login-form {
margin-left: 0; margin-left: 0;
width: 90%; width: 90%;
max-width: 400px; max-width: 400px;
padding: 30px 20px; padding: 30px 20px;
} }
.title { .title {
font-size: 24px; font-size: 24px;
text-align: center; text-align: center;
} }
} }
@media (max-width: 480px) { @media (max-width: 480px) {
.login-form { .login-form {
width: 95%; width: 95%;
padding: 25px 15px; padding: 25px 15px;
} }
.title { .title {
font-size: 20px; font-size: 20px;
} }
} }
</style> </style>