!2259 doc(#I4OBAA): add doc for ErrorLogger inside Layout

* doc: 增加 Layout 组件配合使用说明
* doc: 更新资源文件
* doc: 格式化文档
This commit is contained in:
Argo 2021-12-27 12:13:19 +00:00
parent f97b7b2e30
commit d23c047a00
4 changed files with 269 additions and 254 deletions

View File

@ -424,18 +424,19 @@
"Introduce": "Added component <code>ErrorLogger</code> Through this component, global logs and exceptions can be output uniformly; currently, the <code>Blazor</code> framework does not provide a <code>MVC</code> like < b>Global exception</b> The overall solution, for the time being, you need to use <code>try/catch</code> in the code block for exception capture",
"H1": "Instructions",
"Step1": "1. Add <code>AddLogging</code> to the <code>Startup</code> file to enable the <code>net core</code> system log function",
"Step1Introduce": "使用 <code>AddFileLogger</code> 需要引用 <b>Longbow.Logging</b> 组件包",
"Step1Introduce": "Use <code>AddFileLogger</code> need to reference <b>Longbow.Logging</b> component package",
"Step2": "2. Use <code>BlazorLogger</code> to wrap the content, such as: <code>Body</code> in <code>MainLayout</code>",
"Step3": "3. Use cascading parameters in the code to get examples",
"Step4": "4. Console or <b>IIS</b> output visible log information",
"Step5": "5. 控制是否显示错误明细信息",
"Step5Intro": "通过配置文件 <code>appsettings.json</code>,开发环境下为 <code>appsettings.Development.json</code>,未设置时默认为 <code>false</code> 不显示,默认行为仅做弹窗提示防止敏感信息暴露",
"Step5": "5. Controls whether error details are displayed",
"Step5Intro": "Through the configuration file <code>appsettings.json</code>, which is <code>appsettings.Development.json</code> in the development environment, if not set, it defaults to <code>false</code> and is not displayed. The default behavior is only a pop-up prompt to prevent the exposure of sensitive information",
"Block1Title": "Test",
"Block1Intro": "This function is to obtain the component instance through the cascade parameter and use its function",
"ExceptionTestIntroduce": "In this example code, an error code that divides by zero is written. Because <code>try/catch</code> is used to capture the exception, the error message is displayed in the console below",
"ButtonText": "test",
"Block2Title": "自定义错误处理",
"Block2Intro": "通过设置 <code>OnErrorHandleAsync</code> 回调方法,设置自定义异常处理逻辑"
"Block2Title": "OnErrorHandleAsync",
"Block2Intro": "Set custom exception handling logic by setting <code>OnErrorHandleAsync </code> callback method",
"Tips": "Both the <code>Layout</code> component and the <code>Tab</code> component have built-in <code>ErrorLogger</code> components. Please do not add them in the above two components. The following is the simplified example code"
},
"BootstrapBlazor.Shared.Samples.Splits": {
"Title": "Split",

View File

@ -435,7 +435,8 @@
"ExceptionTestIntroduce": "本例代码中写了一个除以零的错误代码,并且未使用 <code>try/catch</code> 对异常进行捕获,系统并不会崩溃导致不可用,<ul class='ul-demo'><li><code>Debug</code> 模式下会显示错误的 <b>描述信息</b> 与 <b>堆栈信息</b></li><li><code>Release</code> 模式下默认使用 <code>Toast</code> 进行弹窗提示</li></ul><div>可通过设置 <code>ErrorContent</code> 对 <b>异常信息</b> 进行自定义布局显示</div>",
"ButtonText": "测试",
"Block2Title": "自定义错误处理",
"Block2Intro": "通过设置 <code>OnErrorHandleAsync</code> 回调方法,设置自定义异常处理逻辑"
"Block2Intro": "通过设置 <code>OnErrorHandleAsync</code> 回调方法,设置自定义异常处理逻辑",
"Tips": "<code>Layout</code> 组件与 <code>Tab</code> 组件均已内置 <code>ErrorLogger</code> 组件请勿在上述两个组件内额外添加使用,下面是精简后的示例代码"
},
"BootstrapBlazor.Shared.Samples.Splits": {
"Title": "Split 面板分割",

View File

@ -68,4 +68,16 @@
</ErrorLogger>
</DemoBlock>
<Tips class="mt-3">
<p>
@((MarkupString)Localizer["Tips"].Value)
</p>
</Tips>
<Pre>&lt;Layout OnErrorHandleAsync="OnErrorHandleAsync"&gt;
&lt;Main&gt;
@@Body
&lt;/Main&gt;
&lt;/Layout&gt;</Pre>
<AttributeTable Items="@GetAttributes()" />

View File

@ -8,16 +8,17 @@ using BootstrapBlazor.Shared.Components;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace BootstrapBlazor.Shared.Samples
namespace BootstrapBlazor.Shared.Samples;
/// <summary>
///
/// </summary>
public sealed partial class Timelines
{
/// <summary>
///
/// </summary>
public sealed partial class Timelines
{
private readonly ConcurrentQueue<ConsoleMessageItem> _messages = new();
private readonly CancellationTokenSource _cancelTokenSource = new();
@ -67,8 +68,8 @@ namespace BootstrapBlazor.Shared.Samples
Items = new SelectedItem[]
{
new SelectedItem("1",Localizer["SelectedItem1"]){ Active=true },
new SelectedItem("2",Localizer["SelectedItem2"])
new SelectedItem("1", Localizer["SelectedItem1"]) { Active=true },
new SelectedItem("2", Localizer["SelectedItem2"])
};
}
@ -88,18 +89,20 @@ namespace BootstrapBlazor.Shared.Samples
/// <summary>
///
/// </summary>
private IEnumerable<SelectedItem> Items { get; set; }
private IEnumerable<SelectedItem> Items { get; set; } = Enumerable.Empty<SelectedItem>();
/// <summary>
///
/// </summary>
private IEnumerable<TimelineItem> TimelineItems => new TimelineItem[]
{
new TimelineItem {
new TimelineItem
{
Content = Localizer["TimelineItemContent1"],
Description = DateTime.Now.ToString("yyyy-MM-dd")
},
new TimelineItem{
new TimelineItem
{
Content = Localizer["TimelineItemContent2"],
Description = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")
},
@ -228,7 +231,7 @@ namespace BootstrapBlazor.Shared.Samples
Type = "boolean",
ValueList = "true|false",
DefaultValue = "false"
},
}
};
/// <summary>
@ -237,7 +240,6 @@ namespace BootstrapBlazor.Shared.Samples
/// <returns></returns>
private IEnumerable<AttributeItem> GetTimelineItemAttributes() => new AttributeItem[]
{
// TODO: 移动到数据库中
new AttributeItem() {
Name = nameof(TimelineItem.Color),
Description = Localizer["Color"],
@ -274,5 +276,4 @@ namespace BootstrapBlazor.Shared.Samples
DefaultValue = " — "
}
};
}
}