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

249 lines
6.0 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">
<div class="logo">
<img src="/src/assets/images/login/logo3.png" alt="" />
<div>
<span class="btn" @click="router.push({ path: '/api' })">查看API</span>
</div>
2025-06-30 17:26:03 +08:00
</div>
2025-08-25 15:21:34 +08:00
2025-06-27 14:01:42 +08:00
<div class="form">
2025-08-25 11:26:56 +08:00
<div class="title mb-20">欢迎登录数据交换平台</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">
<div class="mb-5 form-item">用户名</div>
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" class="mt-20">
<div class="mb-5 form-item">密码</div>
2025-06-27 14:01:42 +08:00
<el-input
v-model="form.password"
type="password"
placeholder="请输入密码"
tabindex="2"
show-password
2025-06-27 14:01:42 +08:00
>
</el-input>
</el-form-item>
<el-form-item class="mt-30">
2025-06-27 14:01:42 +08:00
<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>
2025-08-25 11:26:56 +08:00
<!-- <div class="tips">
2025-06-30 17:26:03 +08:00
<div style="color: red; text-align: left">
本平台为互联网非涉密平台严禁处理传输国家秘密和工作秘密
</div>
2025-08-25 11:26:56 +08:00
</div> -->
2025-06-30 17:26:03 +08:00
<el-tooltip effect="dark" placement="bottom">
<template #content>
<img :src="appPath.value" alt="" width="180" height="180" />
</template>
</el-tooltip>
2025-06-27 14:01:42 +08:00
</div>
<div class="footer">
2025-06-30 17:26:03 +08:00
ICP备案号 冀ICP备15003849号 技术支持河北秦安安全科技股份有限公司
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-30 17:26:03 +08:00
import { 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";
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
};
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-08-25 11:26:56 +08:00
background-image: url(../../assets/images/login/bg3.png);
2025-06-27 14:01:42 +08:00
background-repeat: no-repeat;
background-size: cover;
2025-06-27 14:01:42 +08:00
}
2025-06-10 09:31:15 +08:00
.login {
width: 100%;
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 {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30px 80px 0 20px;
2025-06-27 14:01:42 +08:00
}
2025-08-25 15:21:34 +08:00
.btn {
border-radius: 4px;
border: 1px solid #3a83fc;
color: #3a83fc;
padding: 5px 8px;
cursor: pointer;
2025-08-25 15:21:34 +08:00
}
2025-06-27 14:01:42 +08:00
.form {
border-radius: 20px;
box-shadow: 0px 5px 20px 0px rgba(137, 149, 174, 0.2);
2025-06-30 17:26:03 +08:00
position: absolute;
right: 270px;
top: 55%;
2025-06-30 17:26:03 +08:00
transform: translateY(-50%);
width: 506px;
height: 590px;
2025-08-25 11:26:56 +08:00
padding: 4px 30px;
2025-06-30 17:26:03 +08:00
background-color: #fff;
z-index: 1;
2025-06-10 09:31:15 +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
// &: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;
// }
.form-item {
font-size: 20px;
2025-06-27 14:01:42 +08:00
}
.title {
font-size: 30px;
2025-08-25 11:26:56 +08:00
color: #3b4f70;
font-weight: bold;
2025-06-27 14:01:42 +08:00
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 {
position: absolute;
bottom: 30px;
width: 445px;
2025-06-27 14:01:42 +08:00
.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 17:26:03 +08:00
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 17:26:03 +08:00
transform: translateX(-50%);
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>