Skip to content

Commit c2f7356

Browse files
committed
Merge branch 'doc-task' into docker
2 parents 0ac1283 + a68be42 commit c2f7356

File tree

5 files changed

+81
-75
lines changed

5 files changed

+81
-75
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Server.Components.Samples.Tutorials;
7+
8+
/// <summary>
9+
/// Contributor
10+
/// </summary>
11+
public sealed class Contributor
12+
{
13+
/// <summary>
14+
/// Gets or sets Name
15+
/// </summary>
16+
public string? Name { get; set; }
17+
18+
/// <summary>
19+
/// Gets or sets Avatar
20+
/// </summary>
21+
public string? Avatar { get; set; }
22+
23+
/// <summary>
24+
/// Gets or sets Description
25+
/// </summary>
26+
public string? Description { get; set; }
27+
28+
/// <summary>
29+
/// Gets or sets Sheet data
30+
/// </summary>
31+
public UniverSheetData? Data { get; set; }
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Server.Components.Samples.Tutorials;
7+
8+
static class MockOnlineContributor
9+
{
10+
public static void Trigger(IDispatchService<Contributor> dispatchService)
11+
{
12+
dispatchService.Dispatch(new DispatchEntry<Contributor>()
13+
{
14+
Name = "OnlineSheet-Demo",
15+
Entry = new Contributor()
16+
{
17+
Name = "Argo Zhang",
18+
Avatar = "/images/Argo-C.png",
19+
Description = "正在更新单元格 A8",
20+
Data = new UniverSheetData()
21+
{
22+
CommandName = "UpdateRange",
23+
Data = new
24+
{
25+
Range = "A8",
26+
Value = $"{DateTime.Now: yyyy-MM-dd HH:mm:ss} Argo 更新此单元格"
27+
}
28+
}
29+
}
30+
});
31+
}
32+
}

src/BootstrapBlazor.Server/Components/Samples/Tutorials/OnlineSheet/OnlineSheet.razor.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ protected override void OnInitialized()
4949
}
5050
}
5151

52+
/// <summary>
53+
/// <inheritdoc/>
54+
/// </summary>
55+
/// <param name="firstRender"></param>
56+
/// <returns></returns>
57+
protected override async Task OnAfterRenderAsync(bool firstRender)
58+
{
59+
await base.OnAfterRenderAsync(firstRender);
60+
61+
if (firstRender)
62+
{
63+
await Task.Delay(5000);
64+
MockOnlineContributor.Trigger(DispatchService);
65+
}
66+
}
67+
5268
private async Task OnReadyAsync()
5369
{
5470
_inited = true;
@@ -63,7 +79,7 @@ private async Task Dispatch(DispatchEntry<Contributor> entry)
6379
return;
6480
}
6581

66-
if (entry.Entry != null)
82+
if (entry is { Name: "OnlineSheet-Demo", Entry: not null })
6783
{
6884
await ToastService.Show(new ToastOption()
6985
{

src/BootstrapBlazor.Server/Extensions/ServiceCollectionExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ public static IServiceCollection AddBootstrapBlazorServerService(this IServiceCo
3535
// 增加 SignalR 服务数据传输大小限制配置
3636
services.Configure<HubOptions>(option => option.MaximumReceiveMessageSize = null);
3737

38-
#if !DEBUG
3938
// 增加后台任务服务
4039
services.AddTaskServices();
4140
services.AddHostedService<ClearTempFilesService>();
42-
services.AddHostedService<MockOnlineContributor>();
43-
#endif
4441
services.AddHostedService<MockReceiveSocketServerService>();
4542
services.AddHostedService<MockSendReceiveSocketServerService>();
4643
services.AddHostedService<MockCustomProtocolSocketServerService>();

src/BootstrapBlazor.Server/Services/MockOnlineContributor.cs

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)