Skip to content

Commit f1494c3

Browse files
committed
refactor: 复写 CheckCanUpload 方法
1 parent d1e1a96 commit f1494c3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,28 @@ protected override void OnParametersSet()
252252
FileIconFile ??= IconTheme.GetIconByKey(ComponentIcons.FileIconFile);
253253
}
254254

255+
/// <summary>
256+
/// <inheritdoc/>
257+
/// </summary>
258+
/// <returns></returns>
259+
protected override bool CheckCanUpload()
260+
{
261+
// 如果组件禁用了 IsDisabled 允许上传但是不出现 + 按钮
262+
if (IsDisabled)
263+
{
264+
return true;
265+
}
266+
267+
// 允许多上传
268+
if (IsMultiple)
269+
{
270+
return !MaxFileCount.HasValue || GetUploadFiles().Count < MaxFileCount;
271+
}
272+
273+
// 只允许单个上传
274+
return UploadFiles.Count == 0;
275+
}
276+
255277
private async Task OnCardFileDelete(UploadFile item)
256278
{
257279
await OnFileDelete(item);

0 commit comments

Comments
 (0)