gohttpdUi/src/views/Login/components/LoginForm.vue

100 lines
2.2 KiB
Vue
Raw Normal View History

2022-01-03 18:01:43 +08:00
<script setup lang="ts">
2022-01-05 17:02:25 +08:00
import { reactive, ref } from 'vue'
2022-01-03 18:01:43 +08:00
import { Form } from '@/components/Form'
2022-01-04 16:53:13 +08:00
import { useI18n } from '@/hooks/web/useI18n'
2022-01-05 17:02:25 +08:00
import { ElButton, ElCheckbox, ElLink } from 'element-plus'
import { required } from '@/utils/formRules'
2022-01-04 16:53:13 +08:00
const { t } = useI18n()
2022-01-03 18:01:43 +08:00
2022-01-05 17:02:25 +08:00
const rules = {
username: [required],
password: [required]
}
const schema = reactive<FormSchema[]>([
2022-01-03 18:01:43 +08:00
{
field: 'username',
2022-01-04 16:53:13 +08:00
label: t('login.username'),
component: 'Input',
colProps: {
span: 24
}
2022-01-03 18:01:43 +08:00
},
{
field: 'password',
2022-01-04 16:53:13 +08:00
label: t('login.password'),
component: 'InputPassword',
colProps: {
span: 24
},
componentProps: {
style: {
width: '100%'
}
}
},
{
2022-01-05 17:02:25 +08:00
field: 'tool',
colProps: {
span: 24
}
},
{
field: 'login',
colProps: {
span: 24
}
},
{
field: 'other',
component: 'Divider',
label: t('login.otherLogin'),
componentProps: {
contentPosition: 'center'
}
},
{
field: 'otherIcon',
colProps: {
span: 24
}
2022-01-03 18:01:43 +08:00
}
2022-01-05 17:02:25 +08:00
])
const iconSize = 30
const remember = ref(false)
2022-01-03 18:01:43 +08:00
</script>
<template>
2022-01-05 17:02:25 +08:00
<Form
:schema="schema"
:rules="rules"
label-position="top"
hide-required-asterisk
size="large"
class="@2xl:max-w-500px @xl:max-w-400px"
>
<template #tool>
<div class="flex justify-between items-center w-[100%]">
<ElCheckbox v-model="remember" :label="t('login.remember')" size="small" />
<ElLink type="primary" :underline="false">{{ t('login.forgetPassword') }}</ElLink>
</div>
</template>
2022-01-04 16:53:13 +08:00
<template #login>
<ElButton type="primary" class="w-[100%]">{{ t('login.login') }}</ElButton>
</template>
2022-01-05 17:02:25 +08:00
<template #otherIcon>
<div class="flex justify-between w-[100%]">
<Icon icon="ant-design:github-filled" :size="iconSize" class="cursor-pointer" />
<Icon icon="ant-design:wechat-filled" :size="iconSize" class="cursor-pointer" />
<Icon icon="ant-design:alipay-circle-filled" :size="iconSize" class="cursor-pointer" />
<Icon icon="ant-design:weibo-circle-filled" :size="iconSize" class="cursor-pointer" />
</div>
</template>
2022-01-04 16:53:13 +08:00
</Form>
2022-01-03 18:01:43 +08:00
</template>