Skip to content

Commit 6f1615f

Browse files
committed
refactor: 精简代码逻辑
1 parent 7a4da96 commit 6f1615f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/BootstrapBlazor/Components/Display/Display.razor.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ private async Task<string> FormatText([DisallowNull] TValue value)
127127

128128
private async Task<string> FormatValueString()
129129
{
130-
string? ret = null;
131-
132-
// 检查 数据源
133-
var valueString = Value?.ToString();
134-
var lookup = await GetLookup();
135-
if (lookup != null)
130+
string? ret = Value?.ToString();
131+
if (!string.IsNullOrEmpty(ret))
136132
{
137-
ret = lookup.FirstOrDefault(i => i.Value.Equals(valueString, LookupStringComparison))?.Text;
133+
var lookup = await GetLookup();
134+
if (lookup != null)
135+
{
136+
ret = lookup.FirstOrDefault(i => i.Value.Equals(ret, LookupStringComparison))?.Text;
137+
}
138138
}
139-
return ret ?? valueString ?? string.Empty;
139+
return ret ?? string.Empty;
140140
}
141141

142142
private Func<TValue, string>? _arrayConvertoString;

0 commit comments

Comments
 (0)