From f224b8b3dd26d985bdbefb8c45f8c1ea8dc30ce8 Mon Sep 17 00:00:00 2001 From: Argo-AscioTech Date: Tue, 25 Jun 2024 14:23:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20webp=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs b/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs index 129c893b3ea..3edf02e5c38 100644 --- a/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs +++ b/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs @@ -124,7 +124,7 @@ private static bool IsImage(UploadFile item) bool CheckExtensions(string fileName) => Path.GetExtension(fileName).ToLowerInvariant() switch { - ".jpg" or ".jpeg" or ".png" or ".bmp" or ".gif" => true, + ".jpg" or ".jpeg" or ".png" or ".bmp" or ".gif" or ".webp" => true, _ => false }; return ret; From 7ad4ba4924c0ec511bbf7471636e168a8f5e2062 Mon Sep 17 00:00:00 2001 From: Argo-AscioTech Date: Tue, 25 Jun 2024 14:24:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20CanPreviewCall?= =?UTF-8?q?back=20=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Upload/CardUpload.razor.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs b/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs index 3edf02e5c38..82bac088172 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 ?? ""); From 35cd2c99529ec6f060c54dbb1657fb5a9e81e47a Mon Sep 17 00:00:00 2001 From: Argo-AscioTech Date: Tue, 25 Jun 2024 14:49:34 +0800 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Extensions/IEditorItemExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From 764876c977674f4329c4a00355a5b0226e7a5bba Mon Sep 17 00:00:00 2001 From: Argo-AscioTech Date: Tue, 25 Jun 2024 14:55:25 +0800 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20=E6=92=A4=E9=94=80=20webp=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs b/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs index 82bac088172..79fa3dd88ae 100644 --- a/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs +++ b/src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs @@ -134,7 +134,7 @@ private bool IsImage(UploadFile item) bool CheckExtensions(string fileName) => Path.GetExtension(fileName).ToLowerInvariant() switch { - ".jpg" or ".jpeg" or ".png" or ".bmp" or ".gif" or ".webp" => true, + ".jpg" or ".jpeg" or ".png" or ".bmp" or ".gif" => true, _ => false }; return ret;