index.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <script setup lang="ts">
  2. import userIcon from '@assets/images/login/user.webp';
  3. import posswordIcon from '@assets/images/login/passowrd.webp';
  4. import enterpriseIcon from '@assets/images/login/enterprise.webp';
  5. import {PreviewOpen, PreviewCloseOne} from '@icon-park/vue-next';
  6. import {useToggle} from '@vueuse/core';
  7. import {RouterLink} from 'vue-router';
  8. import {useI18n} from 'vue-i18n';
  9. import {LDButton, LDLoginInput} from '@components';
  10. import {REGISTER_PATH} from '@routes';
  11. import {useFormState} from './hooks';
  12. import {USER_PASSWORD_LOGIN_STORAGE} from '@utils';
  13. defineOptions({name: 'LoginInfo'});
  14. const [remberPassword, toggleRemberPassword] = useToggle(
  15. Boolean(localStorage.getItem(USER_PASSWORD_LOGIN_STORAGE)),
  16. );
  17. const {t} = useI18n();
  18. const [{isLoading, isCompanyLoading}, onSubmit] = useFormState(remberPassword);
  19. </script>
  20. <template>
  21. <form @submit="onSubmit">
  22. <div class="login-info">
  23. <h2 class="login-title">Login</h2>
  24. <div class="info">
  25. <LDLoginInput
  26. name="name"
  27. :placeholder="t('login.placeholder.userName')"
  28. >
  29. <template #prefix>
  30. <img :src="userIcon" class="input-icon" />
  31. </template>
  32. </LDLoginInput>
  33. <LDLoginInput
  34. name="password"
  35. :placeholder="t('login.placeholder.password')"
  36. type="password"
  37. >
  38. <template #prefix>
  39. <img :src="posswordIcon" class="input-icon" />
  40. </template>
  41. <template #passwordInvisibleIcon>
  42. <PreviewCloseOne theme="filled" />
  43. </template>
  44. <template #passwordvisibleIcon>
  45. <PreviewOpen theme="filled" />
  46. </template>
  47. </LDLoginInput>
  48. <LDLoginInput
  49. name="company"
  50. readonly
  51. :placeholder="t('login.placeholder.company')"
  52. :loading="isCompanyLoading"
  53. >
  54. <template #prefix>
  55. <img :src="enterpriseIcon" class="input-icon" />
  56. </template>
  57. </LDLoginInput>
  58. <div class="operation">
  59. <span
  60. :class="{'rember-password': remberPassword}"
  61. @click="toggleRemberPassword(!remberPassword)"
  62. >
  63. {{t('login.remberPassword')}}
  64. </span>
  65. <span>{{t('login.forgetPassword')}}</span>
  66. </div>
  67. <LDButton class="login-btn" attrType="submit" :loading="isLoading">
  68. {{t('login.loginBtnText')}}
  69. </LDButton>
  70. </div>
  71. <RouterLink :to="REGISTER_PATH" class="regist">
  72. {{t('login.regist')}}
  73. </RouterLink>
  74. </div>
  75. </form>
  76. </template>
  77. <style scoped lang="css">
  78. @import './index.css';
  79. </style>