Optimize code

This commit is contained in:
2023-12-25 17:54:31 +08:00
parent 27a41944c6
commit 6510567fdf
9 changed files with 119 additions and 39 deletions

View File

@@ -91,7 +91,7 @@ const User: React.FC = () => {
<AntdImage
preview={{ mask: <Icon component={IconFatwebEye}></Icon> }}
src={`data:image/png;base64,${value}`}
alt={'avatar'}
alt={'Avatar'}
/>
}
style={{ background: COLOR_BACKGROUND }}
@@ -161,13 +161,21 @@ const User: React.FC = () => {
</>
}
>
{!record.locking &&
{!record.verify &&
!record.locking &&
(!record.expiration || !isPastTime(record.expiration)) &&
(!record.credentialsExpiration || !isPastTime(record.credentialsExpiration)) &&
record.enable ? (
<AntdTag color={'green'}></AntdTag>
) : (
<>
{record.verify ? (
<>
<AntdPopover content={record.verify} trigger={'click'}>
<AntdTag style={{ cursor: 'pointer' }}></AntdTag>
</AntdPopover>
</>
) : undefined}
{record.locking ? <AntdTag></AntdTag> : undefined}
{record.expiration && isPastTime(record.expiration) ? (
<AntdTag></AntdTag>
@@ -430,6 +438,7 @@ const User: React.FC = () => {
form.setFieldValue('id', value.id)
form.setFieldValue('username', value.username)
form.setFieldValue('password', undefined)
form.setFieldValue('verified', !value.verify?.length)
form.setFieldValue('locking', value.locking)
form.setFieldValue('expiration', value.expiration)
form.setFieldValue('credentialsExpiration', value.credentialsExpiration)
@@ -727,6 +736,7 @@ const User: React.FC = () => {
if (!isDrawerEdit && formValues) {
setNewFormValues({
username: formValues.username,
verified: formValues.verified,
locking: formValues.locking,
expiration: formValues.expiration,
credentialsExpiration: formValues.credentialsExpiration,
@@ -771,7 +781,7 @@ const User: React.FC = () => {
src={`data:image/png;base64,${
isDrawerEdit ? formValues?.avatar : avatar
}`}
alt={'avatar'}
alt={'Avatar'}
/>
}
size={100}
@@ -840,6 +850,9 @@ const User: React.FC = () => {
}))}
/>
</AntdForm.Item>
<AntdForm.Item name={'verified'} label={'已验证'}>
<AntdSwitch />
</AntdForm.Item>
<AntdForm.Item
valuePropName={'checked'}
name={'locking'}