feat: 移除RedLocker,更改为自实现 (#169)

用户表增加最后登录时间字段
列表查询多字段模糊查询改为单字段精确查询
WebSocket版本更新检查
前端自定义字段筛选
暗黑模式样式调整
[skip ci]

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
2024-08-12 11:44:14 +08:00
committed by GitHub
parent 4733adede5
commit cd8ed674e0
58 changed files with 585 additions and 320 deletions

View File

@@ -0,0 +1,49 @@
using System.Net.WebSockets;
using NetAdmin.SysComponent.Cache.Sys.Dependency;
namespace NetAdmin.SysComponent.Host.Middlewares;
/// <summary>
/// 版本更新检查中间件
/// </summary>
public sealed class VersionCheckerMiddleware(RequestDelegate next)
{
/// <summary>
/// 主函数
/// </summary>
public async Task InvokeAsync(HttpContext context)
{
if (context.Request.Path == "/ws/version") {
if (context.WebSockets.IsWebSocketRequest) {
var webSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false);
await ConnectionAsync(webSocket).ConfigureAwait(false);
}
else {
context.Response.StatusCode = 400;
}
}
else {
await next(context).ConfigureAwait(false);
}
}
private static async Task ConnectionAsync(WebSocket webSocket)
{
var buffer = new byte[1024];
while (webSocket.State == WebSocketState.Open) {
var receiveResult = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None)
.ConfigureAwait(false);
if (receiveResult.MessageType != WebSocketMessageType.Text) {
continue;
}
var ver = await App.GetService<IToolsCache>().GetVersionAsync().ConfigureAwait(false);
await webSocket.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(ver)), WebSocketMessageType.Text
, true, CancellationToken.None)
.ConfigureAwait(false);
}
await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None)
.ConfigureAwait(false);
}
}