Skip to content

Commit 7d9a6a9

Browse files
authored
doc(CodeEditor): remove sample code for anlysis log (#4221)
* fix: 增加 LoadModule 异常日志 * doc: 更新示例名称 * doc: 临时屏蔽组件分析日志 * test: 增加单元测试
1 parent 830fd76 commit 7d9a6a9

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

src/BootstrapBlazor.Server/Components/Samples/CodeEditors.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
<h3>@Localizer["Title"]</h3>
55

6-
<PackageTips Name="BootstrapBlazor.CodeEditor"></PackageTips>
6+
<div>重构中 ... 稍后开放</div>
7+
8+
@* <PackageTips Name="BootstrapBlazor.CodeEditor"></PackageTips>
79
810
<DemoBlock Title="@Localizer["BasicTitle"]" Introduction="@Localizer["BasicIntro"]">
911
<div class="row form-inline g-3">
@@ -35,4 +37,4 @@
3537
</div>
3638
</DemoBlock>
3739
38-
<AttributeTable Items="GetAttributeItems()" />
40+
<AttributeTable Items="GetAttributeItems()" /> *@

src/BootstrapBlazor.Server/Components/Samples/OnScreenKeyboards.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
<h3>@Localizer["OnScreenKeyboardsTitle"]</h3>
55

6-
<PackageTips Name="BootstrapBlazor.OnScreenKeyboard" />
6+
<div>重构中 ... 稍后开放</div>
7+
8+
@* <PackageTips Name="BootstrapBlazor.OnScreenKeyboard" />
79
810
<p><b>@Localizer["OnScreenKeyboardsBasicTitle"]</b></p>
911
<div class="code-label">Razor</div>
@@ -88,7 +90,7 @@
8890
8991
<AttributeTable Items="@GetKeyboardOptionAttributes()" Title="KeyboardOption" />
9092
91-
<AttributeTable Items="@GetKeyboardEnumAttributes()" Title="KeyboardEnum" />
93+
<AttributeTable Items="@GetKeyboardEnumAttributes()" Title="KeyboardEnum" /> *@
9294

9395
@code {
9496

src/BootstrapBlazor.Server/Components/Samples/SweetAlerts.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ await SwalService.Show(op);</Pre>
140140

141141
<DemoBlock Title="@Localizer["SweetAlertsAutoCloseTitle"]"
142142
Introduction="@Localizer["SweetAlertsAutoCloseIntro"]"
143-
Name="Close">
143+
Name="AutoClose">
144144
<section ignore>@((MarkupString)Localizer["SweetAlertsAutoCloseDescription"].Value)</section>
145145
<Button Icon="fa-solid fa-font-awesome" Text="@Localizer["SweetAlertsAutoCloseButtonText"]" Color="Color.Success" OnClick="@ShowAutoCloseSwal" />
146146
</DemoBlock>

src/BootstrapBlazor/Extensions/JSModuleExtensions.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ public static async Task<JSModule> LoadModule(this IJSRuntime jsRuntime, string
2929
{
3030
fileName = $"{fileName}?v={version}";
3131
}
32-
var jSObjectReference = await jsRuntime.InvokeAsync<IJSObjectReference>(identifier: "import", fileName);
33-
return new JSModule(jSObjectReference);
32+
try
33+
{
34+
var jSObjectReference = await jsRuntime.InvokeAsync<IJSObjectReference>(identifier: "import", fileName);
35+
return new JSModule(jSObjectReference);
36+
}
37+
catch (Exception ex)
38+
{
39+
throw new Exception($"load {fileName} module fail", ex);
40+
}
3441
}
3542

3643
/// <summary>

test/UnitTest/Extensions/JSModuleExtensionsTest.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ public async Task LoadModule_Ok()
1515
await jsRuntime.LoadModule("./mock.js", "test");
1616
}
1717

18+
[Fact]
19+
public async Task LoadModule_Exception()
20+
{
21+
var jsRuntime = new MockJSRuntime();
22+
var ex = await Assert.ThrowsAsync<Exception>(async () => await jsRuntime.LoadModule("./mock.js", "test"));
23+
Assert.Equal("load ./mock.js?v=test module fail", ex.Message);
24+
}
25+
1826
[Fact]
1927
public void GetTypeModuleName_Ok()
2028
{
@@ -85,4 +93,17 @@ class MockComponent : ComponentBase
8593
{
8694

8795
}
96+
97+
class MockJSRuntime : IJSRuntime
98+
{
99+
public ValueTask<TValue> InvokeAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] TValue>(string identifier, object?[]? args)
100+
{
101+
throw new NotImplementedException();
102+
}
103+
104+
public ValueTask<TValue> InvokeAsync<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] TValue>(string identifier, CancellationToken cancellationToken, object?[]? args)
105+
{
106+
throw new NotImplementedException();
107+
}
108+
}
88109
}

0 commit comments

Comments
 (0)