diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index 62b32f2a..b81e479b 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -9,7 +9,6 @@ - diff --git a/Bootstrap.Admin/Controllers/Api/WSController.cs b/Bootstrap.Admin/Controllers/Api/WSController.cs deleted file mode 100644 index 486d70ff..00000000 --- a/Bootstrap.Admin/Controllers/Api/WSController.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Bootstrap.DataAccess; -using Microsoft.AspNetCore.Mvc; -using System.Collections.Generic; -using System.Linq; - -namespace Bootstrap.Admin.Controllers.Api -{ - /// - /// - /// - [Route("api/[controller]")] - public class WSController : Controller - { - /// - /// - /// - /// - /// - [HttpGet] - public List Get() - { - return NotificationHelper.MessagePool.ToList(); - } - } -} \ No newline at end of file diff --git a/Bootstrap.Admin/Startup.cs b/Bootstrap.Admin/Startup.cs index a8e45d78..5bf8620e 100644 --- a/Bootstrap.Admin/Startup.cs +++ b/Bootstrap.Admin/Startup.cs @@ -5,12 +5,14 @@ using Longbow.Cache.Middleware; using Longbow.Configuration; using Longbow.Data; using Longbow.Logging; +using Longbow.Web.WebSockets; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using System; using System.IO; @@ -46,6 +48,7 @@ namespace Bootstrap.Admin { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; + JsonConvert.DefaultSettings = () => options.SerializerSettings; }); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(); } diff --git a/Bootstrap.Admin/Views/Account/Register.cshtml b/Bootstrap.Admin/Views/Account/Register.cshtml index 10463130..5ce9ca1b 100644 --- a/Bootstrap.Admin/Views/Account/Register.cshtml +++ b/Bootstrap.Admin/Views/Account/Register.cshtml @@ -1,11 +1,16 @@ @{ ViewBag.Title = "注册新用户"; - Layout = "~/Views/Shared/_Layout.cshtml"; + Layout = "~/Views/Shared/_Root.cshtml"; } @section css { + + + } @section javascript { + + diff --git a/Bootstrap.Admin/WebSocketHandlerMiddleware.cs b/Bootstrap.Admin/WebSocketHandlerMiddleware.cs deleted file mode 100644 index 22f749c7..00000000 --- a/Bootstrap.Admin/WebSocketHandlerMiddleware.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Longbow.Configuration.Middleware; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using System; -using System.Net.WebSockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace Bootstrap.Admin -{ - public class WebSocketHandlerMiddleware : LgbMiddleware - { - /// - /// - /// - /// - public WebSocketHandlerMiddleware(RequestDelegate next) : base(next) - { - - } - /// - /// - /// - /// - /// - public override async Task Invoke(HttpContext context) - { - if (!context.WebSockets.IsWebSocketRequest || !context.User.Identity.IsAuthenticated) return; - using (var socket = await context.WebSockets.AcceptWebSocketAsync()) - { - while (socket.State == WebSocketState.Open) - { - await Task.Delay(60000); - var data = new ArraySegment(Encoding.UTF8.GetBytes(DateTimeOffset.Now.ToString())); - await socket.SendAsync(data, WebSocketMessageType.Text, true, CancellationToken.None); - } - } - } - } - - public static class WebSocketExtensions - { - /// - /// - /// - /// - public static void UseWebSocketHandler(this IApplicationBuilder app) - { - app.UseWebSockets(); - app.Map("/Foo", builder => builder.UseMiddleware()); - } - } -} \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/html/Test.html b/Bootstrap.Admin/wwwroot/html/Test.html index f4464450..6d888578 100644 --- a/Bootstrap.Admin/wwwroot/html/Test.html +++ b/Bootstrap.Admin/wwwroot/html/Test.html @@ -6,7 +6,7 @@