refactor: 未设置 DisplayName 时显示字段名
This commit is contained in:
parent
667e482687
commit
4202871c29
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Components.Forms
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetDisplayName(this FieldIdentifier fieldIdentifier)
|
public static string GetDisplayName(this FieldIdentifier fieldIdentifier)
|
||||||
{
|
{
|
||||||
var cacheKey = (fieldIdentifier.Model.GetType(), fieldIdentifier.FieldName);
|
var cacheKey = (Type: fieldIdentifier.Model.GetType(), FieldName: fieldIdentifier.FieldName);
|
||||||
if (!DisplayNamesExtensions.TryGetValue(cacheKey, out var dn))
|
if (!DisplayNamesExtensions.TryGetValue(cacheKey, out var dn))
|
||||||
{
|
{
|
||||||
if (BootstrapAdminEditContextDataAnnotationsExtensions.TryGetValidatableProperty(fieldIdentifier, out var propertyInfo))
|
if (BootstrapAdminEditContextDataAnnotationsExtensions.TryGetValidatableProperty(fieldIdentifier, out var propertyInfo))
|
||||||
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Components.Forms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dn ?? "未设置";
|
return dn ?? cacheKey.FieldName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue