diff --git a/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs b/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs index 129c893b3ea..79fa3dd88ae 100644 --- a/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs +++ b/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs @@ -35,6 +35,12 @@ public partial class CardUpload private string PreviewerId => $"prev_{Id}"; + /// + /// 获得/设置 是否允许预览回调方法 默认 null + /// + [Parameter] + public Func? CanPreviewCallback { get; set; } + /// /// 获得/设置 图标模板 /// @@ -108,13 +114,17 @@ protected override void OnParametersSet() ZoomIcon ??= IconTheme.GetIconByKey(ComponentIcons.CardUploadZoomIcon); } - private static bool IsImage(UploadFile item) + private bool IsImage(UploadFile item) { bool ret; if (item.File != null) { ret = item.File.ContentType.Contains("image", StringComparison.OrdinalIgnoreCase) || CheckExtensions(item.File.Name); } + else if (CanPreviewCallback != null) + { + ret = CanPreviewCallback(item); + } else { ret = IsBase64Format() || CheckExtensions(item.FileName ?? item.PrevUrl ?? ""); diff --git a/src/BootstrapBlazor/Extensions/IEditorItemExtensions.cs b/src/BootstrapBlazor/Extensions/IEditorItemExtensions.cs index 757354f3078..dd06272a4e6 100644 --- a/src/BootstrapBlazor/Extensions/IEditorItemExtensions.cs +++ b/src/BootstrapBlazor/Extensions/IEditorItemExtensions.cs @@ -51,8 +51,8 @@ private static bool IsVisible(this IEditorItem item, ItemChangedType changedType { ret = changedType switch { - ItemChangedType.Add => col.IsVisibleWhenAdd.HasValue ? col.IsVisibleWhenAdd.Value : col.Visible, - _ => col.IsVisibleWhenEdit.HasValue ? col.IsVisibleWhenEdit.Value : col.Visible + ItemChangedType.Add => col.IsVisibleWhenAdd ?? col.Visible, + _ => col.IsVisibleWhenEdit ?? col.Visible }; } return ret;