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
cd ~/BootstrapBlazor
curl https://www.blazor.zone/api/dispatch?token=BootstrapBlazor-Publish
git pull
dotnet restore --no-cache
dotnet build src/BootstrapBlazor.Server
dotnet publish src/BootstrapBlazor.Server -c Release
curl https://www.blazor.zone/api/dispatch?token=BootstrapBlazor-Reboot
systemctl stop 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]
[NotNull]
private IDispatchService<RebootMessage>? RebootDispatchService { get; set; }
private IDispatchService<bool>? RebootDispatchService { get; set; }
[NotNull]
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,
Title = payload.Entry.Title,
Delay = 120 * 1000,
ForceDelay = true,
Content = payload.Entry.Content
Category = ToastCategory.Information,
Title = "网站更新中 ...",
IsAutoHide = false,
ChildContent = BootstrapDynamicComponent.CreateComponent<RebootCountDown>().Render(),
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 class="container d-flex position-relative mb-3">
<div class="flip-info">@Localizer["OnlineTimeText"]</div>
<FlipClock ViewMode="FlipClockViewMode.Count" StartValue="Cache.GetStartTime() - DateTimeOffset.Now"></FlipClock>
</div>
</section>

View File

@ -10,32 +10,36 @@ using RouteAttribute = Microsoft.AspNetCore.Mvc.RouteAttribute;
namespace BootstrapBlazor.Server.Controllers.Api;
/// <summary>
///
/// Dispatch 接口
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class DispatchController : ControllerBase
{
/// <summary>
///
/// 消息分发接口
/// </summary>
/// <param name="dispatchService"></param>
/// <param name="token"></param>
/// <returns></returns>
[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 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()
{
Title = "系统更新",
Content = "网站正在获取源码进行更新准备重启,其间短暂时间内将暂停提供服务稍后将自动恢复"
},
Entry = true,
Name = "Reboot"
});
}
else if(data == "57D2EADDEC65BE22E104ADB97778E6B0")
{
dispatchService.Dispatch(new DispatchEntry<bool>()
{
Entry = false,
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; }
}