diff --git a/src/BootstrapBlazor.Server/Components/App.razor b/src/BootstrapBlazor.Server/Components/App.razor index eb9678bd1af..3ac0591918d 100644 --- a/src/BootstrapBlazor.Server/Components/App.razor +++ b/src/BootstrapBlazor.Server/Components/App.razor @@ -1,5 +1,4 @@ @inject IWebHostEnvironment Env -@inject IStringLocalizer Localizer @inject IOptions WebsiteOption diff --git a/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor b/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor index a8dc5abf812..394492a33d5 100644 --- a/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor +++ b/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor @@ -1,4 +1,4 @@ -@inherits LayoutComponentBase +@inherits LayoutComponentBase @layout BaseLayout
@@ -39,7 +39,7 @@ - + diff --git a/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.cs b/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.cs index f2a9ab1f767..98e941318b1 100644 --- a/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Layout/MainLayout.razor.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone @@ -26,10 +26,10 @@ public partial class MainLayout : IDisposable [Inject] [NotNull] - private IStringLocalizer? Localizer { get; set; } + private IStringLocalizer? Localizer { get; set; } [NotNull] - private string? Title { get; set; } + private string? UpdateTooltip { get; set; } [NotNull] private string? ChatTooltip { get; set; } @@ -43,7 +43,7 @@ protected override void OnInitialized() DispatchService.Subscribe(Dispatch); - Title ??= Localizer[nameof(Title)]; + UpdateTooltip ??= Localizer[nameof(UpdateTooltip)]; ChatTooltip ??= Localizer[nameof(ChatTooltip)]; } diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json index f426d1a8c56..cf8eecb8000 100644 --- a/src/BootstrapBlazor.Server/Locales/en-US.json +++ b/src/BootstrapBlazor.Server/Locales/en-US.json @@ -144,6 +144,10 @@ "FooterLi1": "Slider verification code", "FriendLink": "Links" }, + "BootstrapBlazor.Server.Components.Layout.MainLayout": { + "ChatTooltip": "Azure OpenAI", + "UpdateTooltip": "View update log" + }, "BootstrapBlazor.Server.Components.Layout.NavMenu": { "Affix": "Affix", "Ajax": "Ajax", diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json index bbcb3dd69d1..97a8de1054c 100644 --- a/src/BootstrapBlazor.Server/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json @@ -144,6 +144,10 @@ "FooterLi1": "滑块验证码", "FriendLink": "友情链接" }, + "BootstrapBlazor.Server.Components.Layout.MainLayout": { + "ChatTooltip": "Azure OpenAI", + "UpdateTooltip": "点击查看更新日志" + }, "BootstrapBlazor.Server.Components.Layout.NavMenu": { "Affix": "固钉组件 Affix", "Ajax": "数据传输 Ajax", diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs b/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs index 8b4a130b23e..a19543c8353 100644 --- a/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs +++ b/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs @@ -28,13 +28,6 @@ public class EditorItem : ComponentBase, IEditorItem [Parameter] public EventCallback FieldChanged { get; set; } - /// - /// 获得/设置 属性类型 - /// Gets or sets the property type - /// - [NotNull] - public Type? PropertyType { get; set; } - /// /// 获得/设置 ValueExpression 表达式 /// Gets or sets the value expression @@ -42,6 +35,12 @@ public class EditorItem : ComponentBase, IEditorItem [Parameter] public Expression>? FieldExpression { get; set; } + /// + /// + /// + [NotNull] + public Type? PropertyType { get; set; } + /// /// /// @@ -51,70 +50,61 @@ public class EditorItem : ComponentBase, IEditorItem public bool Editable { get; set; } = true; /// - /// 获得/设置 是否忽略显示 - /// Gets or sets whether the field is ignored + /// /// [Parameter] public bool? Ignore { get; set; } /// - /// + /// /// [Parameter] public bool? Readonly { get; set; } /// - /// 获得/设置 是否必填 - /// Gets or sets whether the field is required + /// /// [Parameter] public bool? Required { get; set; } /// - /// 获得/设置 必填错误信息 - /// Gets or sets the required error message + /// /// [Parameter] public string? RequiredErrorMessage { get; set; } /// - /// 获得/设置 是否跳过校验 - /// Gets or sets whether to skip validation + /// /// [Parameter] public bool SkipValidate { get; set; } /// - /// 获得/设置 是否显示标签提示 - /// Gets or sets whether to show the label tooltip + /// /// [Parameter] public bool? ShowLabelTooltip { get; set; } /// - /// 获得/设置 显示文本 - /// Gets or sets the display text + /// /// [Parameter] public string? Text { get; set; } /// - /// 获得/设置 步长 - /// Gets or sets the step value + /// /// [Parameter] public string? Step { get; set; } /// - /// 获得/设置 行数 - /// Gets or sets the row count + /// /// [Parameter] public int Rows { get; set; } /// - /// 获得/设置 列数 - /// Gets or sets the column count + /// /// [Parameter] public int Cols { get; set; } @@ -141,57 +131,49 @@ public class EditorItem : ComponentBase, IEditorItem } /// - /// 获得/设置 组件类型 - /// Gets or sets the component type + /// /// [Parameter] public Type? ComponentType { get; set; } /// - /// 获得/设置 组件参数集合 - /// Gets or sets the component parameters + /// /// [Parameter] public IEnumerable>? ComponentParameters { get; set; } /// - /// 获得/设置 占位符 - /// Gets or sets the placeholder text + /// /// [Parameter] public string? PlaceHolder { get; set; } /// - /// 获得/设置 显示顺序 - /// Gets or sets the display order + /// /// [Parameter] public int Order { get; set; } /// - /// 获得/设置 绑定数据集合 - /// Gets or sets the bound data items + /// /// [Parameter] public IEnumerable? Items { get; set; } /// - /// 获得/设置 Lookup 数据集合 - /// Gets or sets the lookup data items + /// /// [Parameter] public IEnumerable? Lookup { get; set; } /// - /// 获得/设置 选择时是否显示搜索 - /// Gets or sets whether to show search when selecting + /// /// [Parameter] public bool ShowSearchWhenSelect { get; set; } /// - /// 获得/设置 选择时是否固定搜索 - /// Gets or sets whether the search is fixed when selecting + /// /// [Parameter] [Obsolete("已弃用,请删除;Deprecated, please delete")] @@ -199,64 +181,56 @@ public class EditorItem : ComponentBase, IEditorItem public bool IsFixedSearchWhenSelect { get; set; } /// - /// 获得/设置 是否显示为气泡 - /// Gets or sets whether to show as a popover + /// /// [Parameter] public bool IsPopover { get; set; } /// - /// 获得/设置 Lookup 比较方式 - /// Gets or sets the lookup string comparison + /// /// [Parameter] public StringComparison LookupStringComparison { get; set; } = StringComparison.OrdinalIgnoreCase; /// - /// 获得/设置 Lookup 服务键 - /// Gets or sets the lookup service key + /// /// [Parameter] public string? LookupServiceKey { get; set; } /// - /// 获得/设置 Lookup 服务数据 - /// Gets or sets the lookup service data + /// /// [Parameter] public object? LookupServiceData { get; set; } /// - /// 获得/设置 Lookup 服务实例 - /// Gets or sets the lookup service instance + /// /// [Parameter] public ILookupService? LookupService { get; set; } /// - /// 获得/设置 校验规则集合 - /// Gets or sets the validation rules + /// /// [Parameter] public List? ValidateRules { get; set; } - [CascadingParameter] - private List? EditorItems { get; set; } - /// - /// 获得/设置 分组名称 - /// Gets or sets the group name + /// /// [Parameter] public string? GroupName { get; set; } /// - /// 获得/设置 分组顺序 - /// Gets or sets the group order + /// /// [Parameter] public int GroupOrder { get; set; } + [CascadingParameter] + private List? EditorItems { get; set; } + /// /// /// @@ -276,14 +250,12 @@ protected override void OnInitialized() private FieldIdentifier? _fieldIdentifier; /// - /// 获得显示名称 - /// Gets the display name + /// /// public virtual string GetDisplayName() => Text ?? _fieldIdentifier?.GetDisplayName() ?? string.Empty; /// - /// 获得字段名称 - /// Gets the field name + /// /// public string GetFieldName() => _fieldIdentifier?.FieldName ?? string.Empty; } diff --git a/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs b/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs index e3f42ba3360..d07a803386f 100644 --- a/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs +++ b/src/BootstrapBlazor/Components/ValidateForm/ValidateForm.razor.cs @@ -14,7 +14,7 @@ namespace BootstrapBlazor.Components; /// /// ValidateForm 组件类 -/// ValidateForm component类 +/// ValidateForm component /// public partial class ValidateForm { @@ -100,7 +100,7 @@ public partial class ValidateForm /// /// 获得/设置 是否禁用表单内回车自动提交功能 默认 null 未设置 - /// Gets or sets whether禁用表单内回车自动提交功能 Default is null 未Sets + /// Gets or sets whether to disable auto-submit form by enter key. Default is null /// [Parameter] public bool? DisableAutoSubmitFormByEnter { get; set; } @@ -124,10 +124,6 @@ public partial class ValidateForm [NotNull] private IStringLocalizerFactory? LocalizerFactory { get; set; } - /// - /// 验证组件缓存 - /// 验证component缓存 - /// private readonly ConcurrentDictionary<(string FieldName, Type ModelType), (FieldIdentifier FieldIdentifier, IValidateComponent ValidateComponent)> _validatorCache = new(); private readonly ConcurrentDictionary> _validateResults = new(); @@ -195,7 +191,7 @@ internal void AddValidator((string FieldName, Type ModelType) key, (FieldIdentif /// Sets the error message for the specified field /// /// - /// 错误描述信息,可为空,为空时查找资源文件错误描述info,可为空,为空时查找资源文件 + /// 错误描述信息,可为空,为空时查找资源文件Error description info, can be empty, searches resource file when empty public async Task SetError(Expression> expression, string errorMessage) { switch (expression.Body) @@ -435,22 +431,18 @@ private void ValidateDataAnnotations(object? value, ValidationContext context, L if (!find && !string.IsNullOrEmpty(rule.ErrorMessage) && LocalizerFactory.Create(context.ObjectType).TryGetLocalizerString(rule.ErrorMessage, out var msg)) { - // 通过设置 ErrorMessage 检索 rule.ErrorMessage = msg; find = true; } if (!find && LocalizerFactory.Create(rule.GetType()).TryGetLocalizerString(nameof(rule.ErrorMessage), out msg)) { - // 通过 Attribute 检索 rule.ErrorMessage = msg; find = true; } if (!find) { - // 通过 字段.规则名称 检索 - // 查找 resource 资源文件中的 ErrorMessage var ruleNameSpan = rule.GetType().Name.AsSpan(); var index = ruleNameSpan.IndexOf(attributeSpan, StringComparison.OrdinalIgnoreCase); var ruleName = index == -1 ? ruleNameSpan[..] : ruleNameSpan[..index]; @@ -482,11 +474,9 @@ private void ValidateDataAnnotations(object? value, ValidationContext context, L /// private async Task ValidateProperty(ValidationContext context, List results) { - // 获得所有可写属性 var properties = context.ObjectType.GetRuntimeProperties().Where(p => IsPublic(p) && p.IsCanWrite() && p.GetIndexParameters().Length == 0); foreach (var pi in properties) { - // 设置其关联属性字段 var propertyValue = Utility.GetPropertyValue(context.ObjectInstance, pi.Name); var fieldIdentifier = new FieldIdentifier(context.ObjectInstance, pi.Name); context.DisplayName = fieldIdentifier.GetDisplayName(); @@ -496,7 +486,6 @@ private async Task ValidateProperty(ValidationContext context, List(); if (validator.IsNeedValidate) { - // 组件进行验证 await ValidateAsync(validator, context, messages, pi, propertyValue); - // 客户端提示 await validator.ToggleMessage(messages); } results.AddRange(messages); @@ -528,21 +514,17 @@ private async Task ValidateProperty(ValidationContext context, List messages, PropertyInfo pi, object? propertyValue) { - // 单独处理 Upload 组件 if (validator is IUpload uploader) { if (uploader.UploadFiles.Count > 0) { - // 处理多个上传文件 uploader.UploadFiles.ForEach(file => { - // 优先检查 File 流,不需要检查 FileName ValidateDataAnnotations(file.File, context, messages, pi, file.ValidateId); }); } else { - // 未选择文件 if (propertyValue is string) { @@ -559,13 +541,11 @@ private async Task ValidateAsync(IValidateComponent validator, ValidationContext ValidateDataAnnotations(propertyValue, context, messages, pi); if (messages.Count == 0) { - // 自定义验证组件 await validator.ValidatePropertyAsync(propertyValue, context, messages); } if (messages.Count == 0) { - // 联动字段验证 IValidateCollection IValidateCollection? validate; if (context.ObjectInstance is IValidateCollection v) { @@ -612,7 +592,6 @@ private async Task OnValidSubmitForm(EditContext context) } var valid = true; - // 由于可能有异步验证,需要等待异步验证结束 if (_tcs != null) { valid = await _tcs.Task; @@ -691,14 +670,14 @@ public void NotifyFieldChanged(in FieldIdentifier fieldIdentifier, object? value } /// - /// 获取 当前表单值改变的属性集合 - /// Get the set of attributes whose current form values ​​have changed + /// 获得 当前表单值改变的属性集合 + /// Gets the collection of properties whose values have changed in the current form /// public ConcurrentDictionary ValueChangedFields { get; } = new(); /// - /// 获取 当前表单值改变的属性集合 - /// Get the set of attributes whose current form values ​​have changed + /// 获得 当前表单值改变的属性集合 + /// Gets the collection of properties whose values have changed in the current form /// [Obsolete("已弃用,单词拼写错误,请使用 ValueChangedFields,Deprecated Please use ValueChangedFields instead. wrong typo")] [ExcludeFromCodeCoverage] diff --git a/src/BootstrapBlazor/Extensions/ExceptionExtensions.cs b/src/BootstrapBlazor/Extensions/ExceptionExtensions.cs index c9fc73afed2..aec63eda6d8 100644 --- a/src/BootstrapBlazor/Extensions/ExceptionExtensions.cs +++ b/src/BootstrapBlazor/Extensions/ExceptionExtensions.cs @@ -9,14 +9,14 @@ namespace BootstrapBlazor.Components; /// -/// -/// +/// Exception 异常扩展类 +/// Exception extension class /// public static class ExceptionExtensions { /// /// 格式化异常信息 - /// 格式化exception信息 + /// Format exception information /// /// /// @@ -43,8 +43,8 @@ public static string Format(this Exception exception, NameValueCollection? colle } /// - /// 格式化异常信息 - /// 格式化exception信息 + /// 格式化异常信息为 MarkupString + /// Format exception information to MarkupString /// /// ///