From 7cce10c31022d22e772b7ba31e8628b5d9dda857 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Thu, 15 Jun 2023 21:56:21 +0800 Subject: [PATCH] fix: file collection field should default to preview as the title field --- packages/core/client/src/schema-initializer/utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/client/src/schema-initializer/utils.ts b/packages/core/client/src/schema-initializer/utils.ts index 33b9459a7e..7cfe897c91 100644 --- a/packages/core/client/src/schema-initializer/utils.ts +++ b/packages/core/client/src/schema-initializer/utils.ts @@ -82,12 +82,20 @@ export const useTableColumnInitializerFields = () => { ) .map((field) => { const interfaceConfig = getInterface(field.interface); + const isFileCollection = field?.target && getCollection(field?.target)?.template === 'file'; const schema = { name: field.name, 'x-collection-field': `${name}.${field.name}`, 'x-component': 'CollectionField', 'x-read-pretty': true, - 'x-component-props': {}, + 'x-component-props': isFileCollection + ? { + fieldNames: { + label: 'preview', + value: 'id', + }, + } + : {}, }; // interfaceConfig?.schemaInitialize?.(schema, { field, readPretty: true, block: 'Table' }); return {