From 64893e7dad90060f20cc6196163612814d3cce02 Mon Sep 17 00:00:00 2001 From: wren Date: Tue, 24 Mar 2026 21:11:04 +0800 Subject: [PATCH] fix: processFieldName handles object fields ({name, multi_entity}) format Co-Authored-By: Claude Opus 4.6 (1M context) --- app/utils.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/utils.ts b/app/utils.ts index 51946ee..801e4a5 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -10,20 +10,22 @@ dayjs.extend(utc); * 处理字段名,去除类型后缀 * 例如: "字段名_类型" -> "字段名" */ -export function processFieldName(field: string): string { - if (field.includes('_')) { - return field.split('_')[0]; // 只保留类型前面的字段名 +export function processFieldName(field: string | { name: string; [key: string]: unknown }): string { + const name = typeof field === 'string' ? field : (field?.name || ''); + if (name.includes('_')) { + return name.split('_')[0]; // 只保留类型前面的字段名 } - return field; + return name; } /** * 处理字段数组,去除类型后缀并去重 + * 支持字符串和 {name, multi_entity} 对象格式 */ -export function processFieldNames(fields: string[]): string[] { +export function processFieldNames(fields: (string | { name: string; [key: string]: unknown })[]): string[] { // 处理字段,去掉类型后缀 - const processedFields = fields.map(processFieldName); - + const processedFields = fields.map(processFieldName).filter(Boolean); + // 去重并返回 return [...new Set(processedFields)]; }