190 lines
5.0 KiB
Vue
Raw Normal View History

2024-03-31 15:51:00 +08:00
<template>
2024-04-08 20:25:28 +08:00
<div class="container">
2024-04-09 00:23:37 +08:00
<div class="login">
<div class="banner_box"></div>
<div class="login_box">
<div class="login_title">DC Admin</div>
<div class="login_title_desc">国际化路由配置状态管理应有尽有</div>
2024-04-10 00:20:31 +08:00
<div class="login_title_desc">丰富的的页面模板覆盖大多数典型业务场景</div>
2024-04-09 00:23:37 +08:00
<div class="login_form_box">
2024-04-10 00:20:31 +08:00
<a-form :rules="rules" :model="form" layout="vertical" @submit="onSubmit">
<a-form-item field="username" :hide-asterisk="true">
<a-input v-model="form.username" allow-clear placeholder="请输入账号">
<template #prefix>
<icon-user />
</template>
</a-input>
2024-04-09 00:23:37 +08:00
</a-form-item>
2024-04-10 00:20:31 +08:00
<a-form-item field="password" :hide-asterisk="true">
<a-input-password v-model="form.password" allow-clear placeholder="请输入密码">
<template #prefix>
<icon-lock />
</template>
</a-input-password>
2024-04-09 00:23:37 +08:00
</a-form-item>
2024-04-10 00:20:31 +08:00
<a-form-item field="verifyCode" :hide-asterisk="true">
2024-04-09 13:07:38 +08:00
<div class="verifyCode">
2024-04-10 00:20:31 +08:00
<a-input style="width: 160px" v-model="form.verifyCode" allow-clear placeholder="请输入验证码" />
<VerifyCode :content-height="30" :content-width="100" @verify-code-change="verifyCodeChange" />
2024-04-09 13:07:38 +08:00
</div>
</a-form-item>
2024-04-09 00:23:37 +08:00
<a-form-item field="remember">
<div class="remember">
<a-checkbox v-model="form.remember">记住密码</a-checkbox>
<div class="forgot-password">忘记密码</div>
</div>
</a-form-item>
<a-form-item>
2024-04-10 00:20:31 +08:00
<a-button long type="primary" html-type="submit">登录</a-button>
2024-04-09 00:23:37 +08:00
</a-form-item>
</a-form>
</div>
<div class="register">注册账号</div>
<div class="desc">DC-Admin by 兔子先森</div>
</div>
2024-04-08 20:25:28 +08:00
</div>
</div>
2024-03-31 15:51:00 +08:00
</template>
2024-04-08 20:25:28 +08:00
<script setup lang="ts">
2024-04-10 00:20:31 +08:00
import { Message } from "@arco-design/web-vue";
import { useRouter } from "vue-router";
const router = useRouter();
2024-04-09 00:23:37 +08:00
const form = ref({
2024-04-09 13:07:38 +08:00
username: "admin",
password: "123456",
verifyCode: null,
remember: false
2024-04-09 00:23:37 +08:00
});
2024-04-10 00:20:31 +08:00
const rules = ref({
username: [
{
required: true,
message: "请输入账号"
},
{
validator: (value: string, cb: any) => {
if (value !== verify.value.username) {
cb("请输入正确的账号");
} else {
cb();
}
}
}
],
password: [
{
required: true,
message: "请输入密码"
},
{
validator: (value: string, cb: any) => {
if (value !== verify.value.password) {
cb("请输入正确的密码");
} else {
cb();
}
}
}
],
verifyCode: [
{
required: true,
message: "请输入验证码"
},
{
validator: (value: string, cb: any) => {
if (value !== verify.value.verifyCode) {
cb("请输入正确的验证码");
} else {
cb();
}
}
}
]
});
const verify = ref({
username: "admin",
password: "123456",
verifyCode: ""
});
const verifyCodeChange = (code: string) => (verify.value.verifyCode = code);
const onSubmit = ({ errors }: any) => {
if (errors) return;
sessionStorage.setItem("token", "DC-Admin");
Message.success("登录成功");
router.push("/home");
};
2024-04-08 20:25:28 +08:00
</script>
2024-03-31 15:51:00 +08:00
2024-04-08 20:25:28 +08:00
<style lang="scss" scoped>
.container {
height: 100vh;
position: relative;
2024-04-09 00:23:37 +08:00
.login {
width: 1000px;
height: 500px;
left: 50%;
top: 50%;
position: absolute;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
box-shadow: 0 0 8px 1px $color-fill-1;
2024-04-08 20:25:28 +08:00
.banner_box {
2024-04-09 00:23:37 +08:00
width: 650px;
2024-04-08 20:25:28 +08:00
height: 100%;
2024-04-09 00:23:37 +08:00
background: linear-gradient(45deg, #3d65f9, #ffffff);
}
.login_box {
width: 350px;
height: 100%;
box-sizing: border-box;
padding: 40px 30px 30px 30px;
position: relative;
.login_title {
font-size: $font-size-title-2;
color: $color-text-1;
margin-bottom: $margin-text;
}
.login_title_desc {
font-size: $font-size-body-1;
color: $color-text-3;
}
.login_form_box {
margin-top: 28px;
2024-04-09 13:07:38 +08:00
.verifyCode {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
2024-04-09 00:23:37 +08:00
.remember {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.forgot-password {
color: $color-primary;
cursor: pointer;
}
}
}
.register {
text-align: center;
color: $color-text-3;
font-size: $font-size-body-1;
cursor: pointer;
}
.desc {
color: $color-text-4;
font-size: $font-size-body-1;
position: absolute;
bottom: 30px;
2024-04-08 20:25:28 +08:00
}
}
}
}
</style>