perf: If args of setFieldsValue is empty, it will not be executed

pull/38/head
xingyu 2023-10-30 17:47:57 +08:00
parent 29ef568c5f
commit 17f3b4cf40
2 changed files with 8 additions and 16 deletions

View File

@ -7,6 +7,7 @@ import type { UploadFile } from 'ant-design-vue/lib/upload/interface'
import { join } from 'lodash-es' import { join } from 'lodash-es'
import { PlusOutlined } from '@ant-design/icons-vue' import { PlusOutlined } from '@ant-design/icons-vue'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { propTypes } from '@/utils/propTypes'
import { buildShortUUID } from '@/utils/uuid' import { buildShortUUID } from '@/utils/uuid'
import { getAccessToken, getTenantId } from '@/utils/auth' import { getAccessToken, getTenantId } from '@/utils/auth'
import { isArray, isNotEmpty, isUrl } from '@/utils/is' import { isArray, isNotEmpty, isUrl } from '@/utils/is'
@ -32,25 +33,13 @@ const props = defineProps({
type: Array, type: Array,
default: () => ['image/png', 'image/jpeg'], default: () => ['image/png', 'image/jpeg'],
}, },
multiple: { multiple: propTypes.bool.def(false),
type: Boolean,
default: () => false,
},
// //
maxCount: { maxCount: propTypes.number.def(1),
type: Number,
default: () => 1,
},
// //
minCount: { minCount: propTypes.number.def(0),
type: Number,
default: () => 0,
},
// MB // MB
maxSize: { maxSize: propTypes.number.def(5),
type: Number,
default: () => 2,
},
}) })
const emit = defineEmits(['change', 'update:value']) const emit = defineEmits(['change', 'update:value'])

View File

@ -113,6 +113,9 @@ export function useFormEvents({
* @description: Set form value * @description: Set form value
*/ */
async function setFieldsValue(values: Recordable): Promise<void> { async function setFieldsValue(values: Recordable): Promise<void> {
if (Object.keys(values).length === 0)
return
const fields = getAllFields() const fields = getAllFields()
// key 支持 a.b.c 的嵌套写法 // key 支持 a.b.c 的嵌套写法