123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <template>
- <div class="login-box">
- <div class="login-logo">
- <!-- <svg-icon name="logo" :size="45" />-->
- <img src="~@/assets/images/logo-login2.png" width="75" />
- <h1 class="mb-0 ml-2 text-3xl font-bold" style="font-size: 2.675rem;">数据湖数据检索</h1>
- </div>
- <a-form layout="horizontal" :model="state.formInline" @submit.prevent="handleSubmit" style="border: 1px solid #f0f0f0;width: 600px;height: 400px;padding: 100px;">
- <div style="width: 400px;height: 400px; border-radius: 10px;">
- <a-form-item>
- <a-input v-model:value="state.formInline.username" size="large" placeholder="请输入登录账号">
- <template #prefix><user-outlined type="user" /></template>
- </a-input>
- </a-form-item>
- <a-form-item>
- <a-input
- v-model:value="state.formInline.password"
- size="large"
- type="password"
- placeholder="请输入密码"
- autocomplete="new-password"
- >
- <template #prefix><lock-outlined type="user" /></template>
- </a-input>
- </a-form-item>
- <a-form-item>
- <a-button style="border-radius: 8px;" type="primary" html-type="submit" size="large" :loading="state.loading" block>
- 登录
- </a-button>
- </a-form-item>
- </div>
- </a-form>
- </div>
- </template>
- <script setup lang="ts">
- import { reactive } from 'vue';
- import { UserOutlined, LockOutlined, SafetyOutlined } from '@ant-design/icons-vue';
- import { useRoute, useRouter } from 'vue-router';
- import { message, Modal } from 'ant-design-vue';
- import { useUserStore } from '@/store/modules/user';
- import { getImageCaptcha } from '@/api/login';
- import { to } from '@/utils/awaitTo';
- const state = reactive({
- loading: false,
- captcha: '',
- formInline: {
- username: '',
- password: '',
- verifyCode: '',
- captchaId: '',
- },
- });
- const route = useRoute();
- const router = useRouter();
- const userStore = useUserStore();
- const setCaptcha = async () => {
- };
- setCaptcha();
- const handleSubmit = async () => {
- const { username, password, verifyCode } = state.formInline;
- if (username.trim() == '' || password.trim() == '') {
- return message.warning('账号或密码不能为空!');
- }
- /*if (!verifyCode) {
- return message.warning('请输入验证码!');
- }*/
- message.loading('登录中...', 0);
- state.loading = true;
- console.log(state.formInline);
- // params.password = md5(password)
- const [err] = await to(userStore.login(state.formInline));
- if (err) {
- Modal.error({
- title: () => '提示',
- content: () => err.message,
- });
- setCaptcha();
- } else {
- message.success('登录成功!');
- setTimeout(() => router.replace((route.query.redirect as string) ?? '/'));
- }
- state.loading = false;
- message.destroy();
- };
- </script>
- <style lang="less" scoped>
- .login-box {
- display: flex;
- width: 100vw;
- height: 100vh;
- padding-top: 180px;
- background: url('~@/assets/login.svg');
- background-size: 100%;
- flex-direction: column;
- align-items: center;
- .login-logo {
- display: flex;
- margin-bottom: 30px;
- align-items: center;
- .svg-icon {
- font-size: 48px;
- }
- }
- :deep(.ant-form) {
- width: 400px;
- .ant-col {
- width: 100%;
- }
- .ant-form-item-label {
- padding-right: 6px;
- }
- }
- }
- </style>
|