From 2e2add1db2e726e012b61888700d3614b8401737 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Fri, 14 Oct 2022 15:14:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=20JSModuleAu?= =?UTF-8?q?toLoader=20=E5=A2=9E=E5=8A=A0=20Inherited=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/JSModuleAutoLoaderAttribute.cs | 7 ++++++- .../BaseComponents/BootstrapModuleComponentBase.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs b/src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs index f0f1a7c6b..0d771786d 100644 --- a/src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs +++ b/src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs @@ -7,7 +7,7 @@ namespace BootstrapBlazor.Components; /// /// JSModule attribute /// -[AttributeUsage(AttributeTargets.Class, Inherited = false)] +[AttributeUsage(AttributeTargets.Class)] public class JSModuleAutoLoaderAttribute : Attribute { /// @@ -30,6 +30,11 @@ public class JSModuleAutoLoaderAttribute : Attribute /// public bool Relative { get; set; } = true; + /// + /// 获得/设置 是否继承本机制 默认 false + /// + public bool Inherited { get; set; } + /// /// 构造函数 /// diff --git a/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs b/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs index a96d79e92..8e72e4fba 100644 --- a/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs +++ b/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs @@ -42,7 +42,7 @@ public abstract class BootstrapModuleComponentBase : IdComponentBase, IAsyncDisp var type = this.GetType(); var attr = type.GetCustomAttribute(); - if (attr != null) + if (attr != null && attr.Inherited) { string? typeName = null; ModulePath = attr.Path ?? GetTypeName().ToLowerInvariant(); -- Gitee From 1df3a5f58c780369aacc8dd7319c9593866002c9 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Fri, 14 Oct 2022 15:14:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E7=B1=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Popover/IPopover.cs | 16 ----- .../Popover/PopoverConfirmOption.cs | 71 ------------------- 2 files changed, 87 deletions(-) delete mode 100644 src/BootstrapBlazor/Components/Popover/IPopover.cs delete mode 100644 src/BootstrapBlazor/Components/Popover/PopoverConfirmOption.cs diff --git a/src/BootstrapBlazor/Components/Popover/IPopover.cs b/src/BootstrapBlazor/Components/Popover/IPopover.cs deleted file mode 100644 index f69ca36cb..000000000 --- a/src/BootstrapBlazor/Components/Popover/IPopover.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// Website: https://www.blazor.zone or https://argozhang.github.io/ - -namespace BootstrapBlazor.Components; - -/// -/// -/// -public interface IPopover : ITooltip -{ - /// - /// 获得/设置 显示文字 - /// - public string? Content { get; set; } -} diff --git a/src/BootstrapBlazor/Components/Popover/PopoverConfirmOption.cs b/src/BootstrapBlazor/Components/Popover/PopoverConfirmOption.cs deleted file mode 100644 index f7a5de74a..000000000 --- a/src/BootstrapBlazor/Components/Popover/PopoverConfirmOption.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// Website: https://www.blazor.zone or https://argozhang.github.io/ - -namespace BootstrapBlazor.Components; - -/// -/// 确认弹窗相关配置实体类 -/// -public class PopoverConfirmOption -{ - /// - /// 获得/设置 确认回调方法 - /// - public Func? OnConfirm { get; set; } - /// - /// 获得/设置 关闭回调方法 - /// - public Func? OnClose { get; set; } - - /// - /// 获得/设置 确认弹窗回调方法 - /// - public Func? Callback { get; set; } - - /// - /// 获得/设置 弹框按钮触发源组件 Id - /// - public string? ButtonId { get; set; } - - /// - /// 获得/设置 显示标题 - /// - public string? Title { get; set; } - - /// - /// 获得/设置 显示文字 - /// - public string? Content { get; set; } - - /// - /// 获得/设置 确认按钮颜色 - /// - public Color CloseButtonColor { get; set; } = Color.Secondary; - - /// - /// 获得/设置 关闭按钮显示文字 - /// - public string? CloseButtonText { get; set; } - - /// - /// 获得/设置 确认按钮显示文字 - /// - public string? ConfirmButtonText { get; set; } - - /// - /// 获得/设置 确认按钮颜色 - /// - public Color ConfirmButtonColor { get; set; } = Color.Primary; - - /// - /// 获得/设置 确认框图标 - /// - public string Icon { get; set; } = "fa-solid fa-exclamation-circle text-info"; - - /// - /// 获得/设置 自定义样式 默认 null - /// - /// 由 data-bs-custom-class 实现 - public string? CustomClass { get; set; } -} -- Gitee From cc935fefc9ce1e210ace82f9d03f6416db67e4dd Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Fri, 14 Oct 2022 15:21:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=20Inherited=20=E5=8F=82=E6=95=B0=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=9F=BA=E7=B1=BB=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/JSModuleAutoLoaderAttribute.cs | 5 --- .../BootstrapModuleComponentBase.cs | 32 ++++++++++++------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs b/src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs index 0d771786d..9eaa9bbb3 100644 --- a/src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs +++ b/src/BootstrapBlazor/Attributes/JSModuleAutoLoaderAttribute.cs @@ -30,11 +30,6 @@ public class JSModuleAutoLoaderAttribute : Attribute /// public bool Relative { get; set; } = true; - /// - /// 获得/设置 是否继承本机制 默认 false - /// - public bool Inherited { get; set; } - /// /// 构造函数 /// diff --git a/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs b/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs index 8e72e4fba..50a052179 100644 --- a/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs +++ b/src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs @@ -27,6 +27,11 @@ public abstract class BootstrapModuleComponentBase : IdComponentBase, IAsyncDisp private bool Relative { get; set; } + /// + /// 获得/设置 是否继承父类 JSModuleAutoLoader 设置 默认 true + /// + protected bool Inherited { get; set; } + /// /// 获得/设置 是否需要 javascript invoke 默认 false /// @@ -39,21 +44,24 @@ public abstract class BootstrapModuleComponentBase : IdComponentBase, IAsyncDisp { base.OnInitialized(); - var type = this.GetType(); - var attr = type.GetCustomAttribute(); - - if (attr != null && attr.Inherited) + if (Inherited) { - string? typeName = null; - ModulePath = attr.Path ?? GetTypeName().ToLowerInvariant(); - ModuleName = attr.ModuleName ?? GetTypeName(); - JSObjectReference = attr.JSObjectReference; - Relative = attr.Relative; + var type = this.GetType(); + var attr = type.GetCustomAttribute(); - string GetTypeName() + if (attr != null) { - typeName ??= type.GetTypeModuleName(); - return typeName; + string? typeName = null; + ModulePath = attr.Path ?? GetTypeName().ToLowerInvariant(); + ModuleName = attr.ModuleName ?? GetTypeName(); + JSObjectReference = attr.JSObjectReference; + Relative = attr.Relative; + + string GetTypeName() + { + typeName ??= type.GetTypeModuleName(); + return typeName; + } } } } -- Gitee