docking-vue/src/views/login/index.vue

237 lines
5.4 KiB
Vue
Raw Normal View History

2025-06-10 09:31:15 +08:00
<template>
2025-06-27 14:01:42 +08:00
<div class="login login-container">
2025-06-30 14:27:29 +08:00
<div class="logo">
<img src="/src/assets/images/login/logo2.png" alt="" width="250" />
</div>
2025-06-27 14:01:42 +08:00
<div class="form">
2025-06-30 14:27:29 +08:00
<div class="title">欢迎登录</div>
2025-06-27 14:01:42 +08:00
<el-form
ref="formRef"
:model="form"
:rules="rules"
@submit.prevent="fnLogin"
>
<el-form-item prop="username">
2025-06-30 14:27:29 +08:00
<label>账号</label>
2025-06-27 14:01:42 +08:00
<el-input
v-model="form.username"
placeholder="请输入用户名"
tabindex="1"
2025-06-10 09:31:15 +08:00
>
2025-06-27 14:01:42 +08:00
</el-input>
</el-form-item>
<el-form-item prop="password">
2025-06-30 14:27:29 +08:00
<label>密码</label>
2025-06-27 14:01:42 +08:00
<el-input
v-model="form.password"
type="password"
placeholder="请输入密码"
tabindex="2"
>
</el-input>
</el-form-item>
<el-form-item>
<verification v-model:verification-pass="verificationPass" />
</el-form-item>
<el-form-item class="button">
<el-button native-type="submit">登录</el-button>
</el-form-item>
</el-form>
</div>
<div class="footer">
2025-06-30 14:27:29 +08:00
河北秦安安全科技股份有限公司 版权所有 Copy right 2013-2020-v7
2025-06-10 09:31:15 +08:00
</div>
</div>
</template>
<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import Verification from "@/components/verification/index";
import { useUserStore } from "@/pinia/user";
2025-06-27 14:01:42 +08:00
import { getAppPath, getUserInfo, Login } from "@/request/api";
2025-06-10 09:31:15 +08:00
import { debounce } from "throttle-debounce";
2025-06-27 14:01:42 +08:00
import useForm from "@/hooks/useForm.js";
2025-06-10 09:31:15 +08:00
import dayjs from "dayjs";
import { encrypt } from "@/assets/js/aes_secret.js";
2025-06-27 14:01:42 +08:00
import { ElMessage } from "element-plus";
import { useQRCode } from "@vueuse/integrations/useQRCode";
import { getFileUrl } from "@/assets/js/utils.js";
2025-06-10 09:31:15 +08:00
2025-06-30 14:27:29 +08:00
2025-06-27 14:01:42 +08:00
const userStore = useUserStore();
2025-06-10 09:31:15 +08:00
const router = useRouter();
2025-06-27 14:01:42 +08:00
const { formRef, validate } = useForm();
2025-06-10 09:31:15 +08:00
const verificationPass = ref(false);
2025-06-27 14:01:42 +08:00
const appPath = ref("");
2025-06-10 09:31:15 +08:00
const form = ref({
username: "",
password: "",
2025-06-27 14:01:42 +08:00
code: "",
2025-06-10 09:31:15 +08:00
});
const rules = {
username: [{ required: true, message: "请输入用户名", trigger: "blur" }],
password: [{ required: true, message: "请输入密码", trigger: "blur" }],
2025-06-27 14:01:42 +08:00
code: [{ required: true, message: "请输入验证码", trigger: "blur" }],
2025-06-10 09:31:15 +08:00
};
2025-06-27 14:01:42 +08:00
const fnGetAppDownloadPath = async () => {
const { versionmanager } = await getAppPath();
appPath.value = useQRCode(() => getFileUrl() + versionmanager.fileUrl, {
width: 100,
height: 100,
margin: 1,
correctLevel: "H",
});
};
fnGetAppDownloadPath();
2025-06-10 09:31:15 +08:00
const fnLogin = debounce(
1000,
() => {
if (import.meta.env.DEV) {
fnSubmitLogin();
return;
}
2025-06-27 14:01:42 +08:00
if (verificationPass.value) {
fnSubmitLogin();
} else {
ElMessage.warning("请进行登录验证");
}
2025-06-10 09:31:15 +08:00
},
{ atBegin: true }
);
const fnSubmitLogin = async () => {
await validate("请输入用户名密码");
const { token } = await Login({
username: encrypt(form.value.username),
password: encrypt(form.value.password),
});
await userStore.setToken(token);
await userStore.setTokenTime(dayjs().format("YYYY-MM-DD HH:mm:ss"));
const { user } = await getUserInfo();
userStore.setUserInfo({
...userStore.getUserInfo,
...user,
});
await router.replace("/index");
};
</script>
<style scoped lang="scss">
2025-06-27 14:01:42 +08:00
.login-container {
height: 100vh;
width: 100%;
background-color: #2d3a4b;
overflow: hidden;
2025-06-30 14:27:29 +08:00
background-image: url(../../assets/images/login/bg2.png);
2025-06-27 14:01:42 +08:00
background-repeat: no-repeat;
2025-06-30 14:27:29 +08:00
background-size: 70% 100%;
float: left;
position: relative;
2025-06-27 14:01:42 +08:00
}
2025-06-30 14:27:29 +08:00
2025-06-10 09:31:15 +08:00
.login {
width: 100%;
max-width: 1920px;
margin: 0 auto;
height: 100vh;
position: relative;
2025-06-27 14:01:42 +08:00
background-color: #fff;
2025-06-10 09:31:15 +08:00
2025-06-27 14:01:42 +08:00
.logo {
2025-06-30 14:27:29 +08:00
top: 20px;
left: 20px;
position: absolute;
2025-06-27 14:01:42 +08:00
}
2025-06-10 09:31:15 +08:00
2025-06-27 14:01:42 +08:00
.form {
2025-06-30 14:27:29 +08:00
float: right;
padding-left: 100px;
padding-right: 100px;
padding-top: 150px;
width: 30%;
height: 100%;
//padding: 40px 50px;
background-color: #d6def2;
//z-index: 1;
2025-06-10 09:31:15 +08:00
2025-06-27 14:01:42 +08:00
&:after {
content: "";
position: absolute;
top: 40px;
left: -30px;
width: calc(100% + 60px);
height: calc(100% - 80px);
border-radius: 10px;
background-color: rgba(255, 255, 255, 0.3);
z-index: -1;
}
2025-06-10 09:31:15 +08:00
2025-06-27 14:01:42 +08:00
&:before {
content: "";
position: absolute;
top: 20px;
left: -15px;
width: calc(100% + 30px);
height: calc(100% - 40px);
border-radius: 10px;
background-color: rgba(255, 255, 255, 0.5);
z-index: -2;
}
2025-06-10 09:31:15 +08:00
2025-06-27 14:01:42 +08:00
.title {
font-size: 20px;
color: #000;
line-height: 60px;
}
2025-06-10 09:31:15 +08:00
2025-06-27 14:01:42 +08:00
.el-form-item {
.el-input {
height: 40px;
}
}
2025-06-10 09:31:15 +08:00
2025-06-27 14:01:42 +08:00
.button {
.el-button {
background: #0a7dfe;
height: 45px;
width: 100%;
color: #ffffff;
margin-top: 10px;
2025-06-10 09:31:15 +08:00
}
}
2025-06-27 14:01:42 +08:00
.tooltip {
width: max-content;
cursor: pointer;
position: absolute;
right: 50px;
}
}
.footer {
width: 100%;
height: 80px;
font-size: 14px;
2025-06-30 14:27:29 +08:00
color: white;
//color: rgba(0, 0, 0, 0.5);
2025-06-27 14:01:42 +08:00
text-align: center;
position: absolute;
bottom: 0;
left: 50%;
2025-06-30 14:27:29 +08:00
transform: translateX(-70%);
2025-06-27 14:01:42 +08:00
z-index: 1;
line-height: 80px;
2025-06-10 09:31:15 +08:00
}
}
:deep {
.el-input-group__prepend {
padding-top: 5px !important;
}
2025-06-27 14:01:42 +08:00
.el-carousel__indicators {
display: none;
}
2025-06-10 09:31:15 +08:00
}
</style>