index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="login-box">
  3. <div class="login-logo">
  4. <!-- <svg-icon name="logo" :size="45" />-->
  5. <img src="~@/assets/images/logo-login2.png" width="75" />
  6. <h1 class="mb-0 ml-2 text-3xl font-bold" style="font-size: 2.675rem;">数据湖数据检索</h1>
  7. </div>
  8. <a-form layout="horizontal" :model="state.formInline" @submit.prevent="handleSubmit" style="border: 1px solid #f0f0f0;width: 600px;height: 400px;padding: 100px;">
  9. <div style="width: 400px;height: 400px; border-radius: 10px;">
  10. <a-form-item>
  11. <a-input v-model:value="state.formInline.username" size="large" placeholder="请输入登录账号">
  12. <template #prefix><user-outlined type="user" /></template>
  13. </a-input>
  14. </a-form-item>
  15. <a-form-item>
  16. <a-input
  17. v-model:value="state.formInline.password"
  18. size="large"
  19. type="password"
  20. placeholder="请输入密码"
  21. autocomplete="new-password"
  22. >
  23. <template #prefix><lock-outlined type="user" /></template>
  24. </a-input>
  25. </a-form-item>
  26. <a-form-item>
  27. <a-button style="border-radius: 8px;" type="primary" html-type="submit" size="large" :loading="state.loading" block>
  28. 登录
  29. </a-button>
  30. </a-form-item>
  31. </div>
  32. </a-form>
  33. </div>
  34. </template>
  35. <script setup lang="ts">
  36. import { reactive } from 'vue';
  37. import { UserOutlined, LockOutlined, SafetyOutlined } from '@ant-design/icons-vue';
  38. import { useRoute, useRouter } from 'vue-router';
  39. import { message, Modal } from 'ant-design-vue';
  40. import { useUserStore } from '@/store/modules/user';
  41. import { getImageCaptcha } from '@/api/login';
  42. import { to } from '@/utils/awaitTo';
  43. const state = reactive({
  44. loading: false,
  45. captcha: '',
  46. formInline: {
  47. username: '',
  48. password: '',
  49. verifyCode: '',
  50. captchaId: '',
  51. },
  52. });
  53. const route = useRoute();
  54. const router = useRouter();
  55. const userStore = useUserStore();
  56. const setCaptcha = async () => {
  57. };
  58. setCaptcha();
  59. const handleSubmit = async () => {
  60. const { username, password, verifyCode } = state.formInline;
  61. if (username.trim() == '' || password.trim() == '') {
  62. return message.warning('账号或密码不能为空!');
  63. }
  64. /*if (!verifyCode) {
  65. return message.warning('请输入验证码!');
  66. }*/
  67. message.loading('登录中...', 0);
  68. state.loading = true;
  69. console.log(state.formInline);
  70. // params.password = md5(password)
  71. const [err] = await to(userStore.login(state.formInline));
  72. if (err) {
  73. Modal.error({
  74. title: () => '提示',
  75. content: () => err.message,
  76. });
  77. setCaptcha();
  78. } else {
  79. message.success('登录成功!');
  80. setTimeout(() => router.replace((route.query.redirect as string) ?? '/'));
  81. }
  82. state.loading = false;
  83. message.destroy();
  84. };
  85. </script>
  86. <style lang="less" scoped>
  87. .login-box {
  88. display: flex;
  89. width: 100vw;
  90. height: 100vh;
  91. padding-top: 180px;
  92. background: url('~@/assets/login.svg');
  93. background-size: 100%;
  94. flex-direction: column;
  95. align-items: center;
  96. .login-logo {
  97. display: flex;
  98. margin-bottom: 30px;
  99. align-items: center;
  100. .svg-icon {
  101. font-size: 48px;
  102. }
  103. }
  104. :deep(.ant-form) {
  105. width: 400px;
  106. .ant-col {
  107. width: 100%;
  108. }
  109. .ant-form-item-label {
  110. padding-right: 6px;
  111. }
  112. }
  113. }
  114. </style>