doc(Reboot): update Reboot notification (#3084)

* chore: 更新脚本

* feat: 增加网站发布重启消息通知
This commit is contained in:
Argo Zhang 2024-03-17 19:46:34 +08:00 committed by GitHub
parent d210658ea6
commit 2a4d52761d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 47 additions and 43 deletions

View File

@ -1,9 +1,12 @@
#! /bin/bash #! /bin/bash
cd ~/BootstrapBlazor cd ~/BootstrapBlazor
curl https://www.blazor.zone/api/dispatch?token=BootstrapBlazor-Publish
git pull git pull
dotnet restore --no-cache dotnet build src/BootstrapBlazor.Server
dotnet publish src/BootstrapBlazor.Server -c Release dotnet publish src/BootstrapBlazor.Server -c Release
curl https://www.blazor.zone/api/dispatch?token=BootstrapBlazor-Reboot
systemctl stop ba.blazor systemctl stop ba.blazor
\cp -fr ~/BootstrapBlazor/src/BootstrapBlazor.Server/bin/Release/net8.0/publish/* /usr/local/ba/blazor \cp -fr ~/BootstrapBlazor/src/BootstrapBlazor.Server/bin/Release/net8.0/publish/* /usr/local/ba/blazor

View File

@ -0,0 +1,3 @@
<div class="bb-reboot-clock">
<FlipClock ViewMode="FlipClockViewMode.CountDown" ShowHour="false" StartValue="TimeSpan.FromMinutes(2)"></FlipClock>
</div>

View File

@ -0,0 +1,10 @@
::deep .bb-flip-clock {
--bb-flip-clock-height: 100px;
--bb-flip-clock-bg: radial-gradient(ellipse at center, #ac85f1 0%, #833bf8 100%);
--bb-flip-clock-font-size: 46px;
--bb-flip-clock-list-margin-right: 20px;
--bb-flip-clock-item-margin: 5px;
--bb-flip-clock-item-width: 46px;
--bb-flip-clock-item-height: 60px;
--bb-flip-clock-number-bg: #333;
}

View File

@ -29,7 +29,7 @@ public partial class BaseLayout : IDisposable
[Inject] [Inject]
[NotNull] [NotNull]
private IDispatchService<RebootMessage>? RebootDispatchService { get; set; } private IDispatchService<bool>? RebootDispatchService { get; set; }
[NotNull] [NotNull]
private string? FlowText { get; set; } private string? FlowText { get; set; }
@ -90,19 +90,25 @@ public partial class BaseLayout : IDisposable
} }
} }
private async Task NotifyReboot(DispatchEntry<RebootMessage> payload) private ToastOption? _option;
private async Task NotifyReboot(DispatchEntry<bool> payload)
{ {
if (payload.Entry != null) if (payload.Entry)
{ {
var option = new ToastOption() _option = new ToastOption()
{ {
Category = ToastCategory.Error, Category = ToastCategory.Information,
Title = payload.Entry.Title, Title = "网站更新中 ...",
Delay = 120 * 1000, IsAutoHide = false,
ForceDelay = true, ChildContent = BootstrapDynamicComponent.CreateComponent<RebootCountDown>().Render(),
Content = payload.Entry.Content PreventDuplicates = true
}; };
await Toast.Show(option); await Toast.Show(_option);
}
else if (_option != null)
{
await InvokeAsync(_option.Close);
} }
} }

View File

@ -160,6 +160,5 @@
</div> </div>
<div class="container d-flex position-relative mb-3"> <div class="container d-flex position-relative mb-3">
<div class="flip-info">@Localizer["OnlineTimeText"]</div> <div class="flip-info">@Localizer["OnlineTimeText"]</div>
<FlipClock ViewMode="FlipClockViewMode.Count" StartValue="Cache.GetStartTime() - DateTimeOffset.Now"></FlipClock>
</div> </div>
</section> </section>

View File

@ -10,32 +10,36 @@ using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
namespace BootstrapBlazor.Server.Controllers.Api; namespace BootstrapBlazor.Server.Controllers.Api;
/// <summary> /// <summary>
/// /// Dispatch 接口
/// </summary> /// </summary>
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class DispatchController : ControllerBase public class DispatchController : ControllerBase
{ {
/// <summary> /// <summary>
/// /// 消息分发接口
/// </summary> /// </summary>
/// <param name="dispatchService"></param> /// <param name="dispatchService"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public IActionResult Get([FromServices] IDispatchService<RebootMessage> dispatchService, [FromQuery] string token = "") public IActionResult Get([FromServices] IDispatchService<bool> dispatchService, [FromQuery] string token = "")
{ {
var hash = MD5.HashData(Encoding.UTF8.GetBytes(token)); var hash = MD5.HashData(Encoding.UTF8.GetBytes(token));
var data = string.Join("", hash.Select(i => i.ToString("X2"))); var data = string.Join("", hash.Select(i => i.ToString("X2")));
if (data == "B2467CFB16008BC208F674B1E2581149") if (data == "96BD3413D0780A6E4F69CC48C835BB80")
{ {
dispatchService.Dispatch(new DispatchEntry<RebootMessage>() dispatchService.Dispatch(new DispatchEntry<bool>()
{ {
Entry = new() Entry = true,
Name = "Reboot"
});
}
else if(data == "57D2EADDEC65BE22E104ADB97778E6B0")
{ {
Title = "系统更新", dispatchService.Dispatch(new DispatchEntry<bool>()
Content = "网站正在获取源码进行更新准备重启,其间短暂时间内将暂停提供服务稍后将自动恢复" {
}, Entry = false,
Name = "Reboot" Name = "Reboot"
}); });
} }

View File

@ -1,21 +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.Server.Data;
/// <summary>
/// 网站重启消息类
/// </summary>
public class RebootMessage
{
/// <summary>
/// 消息标题
/// </summary>
public required string Title { get; init; }
/// <summary>
/// 消息内容
/// </summary>
public required string Content { get; init; }
}