LoginForm.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <script setup lang="ts">
  2. import { reactive, ref } from 'vue'
  3. import { Form } from '@/components/Form'
  4. import { useI18n } from '@/hooks/web/useI18n'
  5. import { ElButton, ElCheckbox, ElLink } from 'element-plus'
  6. import { required } from '@/utils/formRules'
  7. const { t } = useI18n()
  8. const rules = {
  9. username: [required],
  10. password: [required]
  11. }
  12. const schema = reactive<FormSchema[]>([
  13. {
  14. field: 'username',
  15. label: t('login.username'),
  16. component: 'Input',
  17. colProps: {
  18. span: 24
  19. }
  20. },
  21. {
  22. field: 'password',
  23. label: t('login.password'),
  24. component: 'InputPassword',
  25. colProps: {
  26. span: 24
  27. },
  28. componentProps: {
  29. style: {
  30. width: '100%'
  31. }
  32. }
  33. },
  34. {
  35. field: 'tool',
  36. colProps: {
  37. span: 24
  38. }
  39. },
  40. {
  41. field: 'login',
  42. colProps: {
  43. span: 24
  44. }
  45. },
  46. {
  47. field: 'other',
  48. component: 'Divider',
  49. label: t('login.otherLogin'),
  50. componentProps: {
  51. contentPosition: 'center'
  52. }
  53. },
  54. {
  55. field: 'otherIcon',
  56. colProps: {
  57. span: 24
  58. }
  59. }
  60. ])
  61. const iconSize = 30
  62. const remember = ref(false)
  63. </script>
  64. <template>
  65. <Form :schema="schema" :rules="rules" label-position="top" hide-required-asterisk size="large">
  66. <template #tool>
  67. <div class="flex justify-between items-center w-[100%]">
  68. <ElCheckbox v-model="remember" :label="t('login.remember')" size="small" />
  69. <ElLink type="primary" :underline="false">{{ t('login.forgetPassword') }}</ElLink>
  70. </div>
  71. </template>
  72. <template #login>
  73. <ElButton type="primary" class="w-[100%]">{{ t('login.login') }}</ElButton>
  74. </template>
  75. <template #otherIcon>
  76. <div class="flex justify-between w-[100%]">
  77. <Icon icon="ant-design:github-filled" :size="iconSize" class="cursor-pointer anticon" />
  78. <Icon icon="ant-design:wechat-filled" :size="iconSize" class="cursor-pointer anticon" />
  79. <Icon
  80. icon="ant-design:alipay-circle-filled"
  81. :size="iconSize"
  82. class="cursor-pointer anticon"
  83. />
  84. <Icon
  85. icon="ant-design:weibo-circle-filled"
  86. :size="iconSize"
  87. class="cursor-pointer anticon"
  88. />
  89. </div>
  90. </template>
  91. </Form>
  92. </template>
  93. <style lang="less" scoped>
  94. :deep(.anticon) {
  95. &:hover {
  96. color: var(--el-color-primary) !important;
  97. }
  98. }
  99. </style>