wip(Login): Login developing

This commit is contained in:
陈凯龙 2022-01-04 16:53:13 +08:00
parent 4d52f7bf58
commit 77097c8d92
11 changed files with 1542 additions and 1493 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 262 KiB

BIN
src/assets/imgs/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -114,20 +114,26 @@ export default defineComponent({
return ( return (
<ElFormItem {...(item.formItemProps || {})} prop={item.field} label={item.label}> <ElFormItem {...(item.formItemProps || {})} prop={item.field} label={item.label}>
{() => { {() => {
const Com = componentMap[item.component as string] as ReturnType<typeof defineComponent> if (slots[item.field]) {
return ( return getSlot(slots, item.field, { item })
<Com } else {
vModel={formModel.value[item.field]} const Com = componentMap[item.component as string] as ReturnType<
{...(autoSetPlaceholder && setTextPlaceholder(item))} typeof defineComponent
{...setComponentProps(item)}
{...(notRenderOptions.includes(item?.component as string) &&
item?.componentProps?.options
? { options: item?.componentProps?.options || [] }
: {})}
> >
{{ ...slotsMap }} return (
</Com> <Com
) vModel={formModel.value[item.field]}
{...(autoSetPlaceholder && setTextPlaceholder(item))}
{...setComponentProps(item)}
{...(notRenderOptions.includes(item?.component as string) &&
item?.componentProps?.options
? { options: item?.componentProps?.options || [] }
: {})}
>
{{ ...slotsMap }}
</Com>
)
}
}} }}
</ElFormItem> </ElFormItem>
) )

View File

@ -56,7 +56,7 @@ const getIconName = computed(() =>
<div :class="[prefixCls, `${prefixCls}--${configGlobal?.size}`]"> <div :class="[prefixCls, `${prefixCls}--${configGlobal?.size}`]">
<ElInput v-bind="$attrs" v-model="valueRef" :type="textType"> <ElInput v-bind="$attrs" v-model="valueRef" :type="textType">
<template #suffix> <template #suffix>
<Icon class="el-input__icon" :icon="getIconName" @click="changeTextType" /> <Icon class="el-input__icon cursor-pointer" :icon="getIconName" @click="changeTextType" />
</template> </template>
</ElInput> </ElInput>
<div <div

View File

@ -11,6 +11,13 @@ export default {
large: 'Large', large: 'Large',
small: 'Small' small: 'Small'
}, },
login: {
message1: 'Welcome to the system',
message2: 'Backstage management system',
username: 'Username',
password: 'password',
login: 'Sign in'
},
formDemo: { formDemo: {
input: 'Input', input: 'Input',
inputNumber: 'InputNumber', inputNumber: 'InputNumber',

View File

@ -11,6 +11,13 @@ export default {
large: '大', large: '大',
small: '小' small: '小'
}, },
login: {
message1: '欢迎使用本系统',
message2: '开箱即用的中后台管理系统',
username: '用户名',
password: '密码',
login: '登录'
},
formDemo: { formDemo: {
input: '输入框', input: '输入框',
inputNumber: '数字输入框', inputNumber: '数字输入框',

View File

@ -1,13 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { LoginForm } from './components' import { LoginForm } from './components'
import { ElCard } from 'element-plus' // import { ElCard } from 'element-plus'
// import { ThemeSwitch } from '@/components/ThemeSwitch' // import { ThemeSwitch } from '@/components/ThemeSwitch'
// import { LocaleDropdown } from '@/components/LocaleDropdown' // import { LocaleDropdown } from '@/components/LocaleDropdown'
// import { SizeDropdown } from '@/components/SizeDropdown' // import { SizeDropdown } from '@/components/SizeDropdown'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
// import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
// const { t } = useI18n() const { t } = useI18n()
const { getPrefixCls } = useDesign() const { getPrefixCls } = useDesign()
@ -15,22 +15,26 @@ const prefixCls = getPrefixCls('login')
</script> </script>
<template> <template>
<div :class="prefixCls" class="h-[calc(100%)] relative"> <div :class="prefixCls" class="h-[100%] relative">
<div <div class="relative h-full flex mx-auto border-dark-50 border-2px">
class="container relative h-full py-2 mx-auto flex @2xl:max-w-1600px @xl:max-w-1000px @lg:max-w-600px @md:max-w-500px @sm:max-w-500px" <div
> :class="`${prefixCls}__left`"
<div class="flex-1 <lg:hidden"> class="flex-1 bg-gray-500 bg-opacity-20 relative p-30px <xl:hidden"
<img src="@/assets/svgs/login-box-bg.svg" alt="" class="w-1/2 m-auto" /> >
<div class="flex items-center text-white">
<img src="@/assets/imgs/logo.png" alt="" class="w-48px h-48px mr-10px" />
<span class="text-20px font-bold">ButterflyAdmin</span>
</div>
<div :class="`${prefixCls}__left--message`" class="absolute top-[50%] left-[50%]">
<img src="@/assets/svgs/login-box-bg.svg" alt="" class="w-350px" />
<div class="text-3xl text-white">{{ t('login.message1') }}</div>
<div class="mt-5 font-normal text-white text-14px"> {{ t('login.message2') }} </div>
</div>
</div> </div>
<div class="flex-1"> <div :class="`${prefixCls}__right`" class="flex-1 p-30px relative">
<ElCard> <div :class="`${prefixCls}__form`" class="absolute top-[50%] left-[50%] w-[40%]">
<template #header>
<div>
<span>Card name</span>
</div>
</template>
<LoginForm /> <LoginForm />
</ElCard> </div>
</div> </div>
</div> </div>
</div> </div>
@ -40,25 +44,27 @@ const prefixCls = getPrefixCls('login')
@prefix-cls: ~'@{namespace}-login'; @prefix-cls: ~'@{namespace}-login';
.@{prefix-cls} { .@{prefix-cls} {
&::before { &__left {
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
background-image: url('@/assets/svgs/login-light-bg.svg');
background-position: center;
background-repeat: no-repeat;
content: '';
}
}
.dark {
.@{prefix-cls} {
&::before { &::before {
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
background-image: url('@/assets/svgs/login-dark-bg.svg'); background-image: url('@/assets/svgs/login-dark-bg.svg');
background-position: center;
background-repeat: no-repeat;
content: '';
} }
&--message {
transform: translate(-50%, -50%);
}
}
&__form {
transform: translate(-50%, -50%);
} }
} }
</style> </style>

View File

@ -1,18 +1,42 @@
<script setup lang="ts"> <script setup lang="ts">
import { Form } from '@/components/Form' import { Form } from '@/components/Form'
import { useI18n } from '@/hooks/web/useI18n'
import { ElButton } from 'element-plus'
const { t } = useI18n()
const schema: FormSchema[] = [ const schema: FormSchema[] = [
{ {
field: 'username', field: 'username',
component: 'Input' label: t('login.username'),
component: 'Input',
colProps: {
span: 24
}
}, },
{ {
field: 'password', field: 'password',
component: 'InputPassword' label: t('login.password'),
component: 'InputPassword',
colProps: {
span: 24
},
componentProps: {
style: {
width: '100%'
}
}
},
{
field: 'login'
} }
] ]
</script> </script>
<template> <template>
<Form :schema="schema" :label-width="0" /> <Form :schema="schema" label-position="top">
<template #login>
<ElButton type="primary" class="w-[100%]">{{ t('login.login') }}</ElButton>
</template>
</Form>
</template> </template>