Skip to content

Commit 037a478

Browse files
committed
refactor: 更新 ValueString 格式化方法
1 parent 1139855 commit 037a478

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/BootstrapBlazor/Components/Upload/InputUpload.razor.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,6 @@ protected override void OnParametersSet()
102102
DeleteButtonIcon ??= IconTheme.GetIconByKey(ComponentIcons.InputUploadDeleteButtonIcon);
103103
}
104104

105-
/// <summary>
106-
/// <inheritdoc/>
107-
/// </summary>
108-
protected override string? FormatValueAsString(TValue? value)
109-
{
110-
return CurrentValue?.ToString();
111-
}
112-
113105
private async Task OnDeleteFile()
114106
{
115107
foreach (var item in UploadFiles)

src/BootstrapBlazor/Components/Upload/UploadBase.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,33 @@ public abstract class UploadBase<TValue> : ValidateBase<TValue>, IUpload
9494
/// </summary>
9595
public List<UploadFile> UploadFiles { get; } = [];
9696

97+
/// <summary>
98+
/// <inheritdoc/>
99+
/// </summary>
100+
protected override string? FormatValueAsString(TValue? value)
101+
{
102+
if (value is null)
103+
{
104+
return null;
105+
}
106+
else if (value is IEnumerable<IBrowserFile> files)
107+
{
108+
return string.Join(";", files.Select(i => i.Name));
109+
}
110+
else if (value is IBrowserFile file)
111+
{
112+
return file.Name;
113+
}
114+
else if (value is IEnumerable<string> strings)
115+
{
116+
return string.Join(";", strings);
117+
}
118+
else
119+
{
120+
return base.FormatValueAsString(value);
121+
}
122+
}
123+
97124
/// <summary>
98125
/// <inheritdoc/>
99126
/// </summary>

0 commit comments

Comments
 (0)