From 08b932e20d7da7c3cee91717460418dfeb64e0b8 Mon Sep 17 00:00:00 2001 From: AnduinXue Date: Mon, 27 Nov 2023 17:50:18 +0000 Subject: [PATCH] Better UI. --- .../Controllers/GamesController.cs | 4 ++-- .../Middlewares/AllowCrossOriginMiddleware.cs | 2 +- .../Views/Games/GetHtml.cshtml | 24 +++++++++++++++---- .../Views/Shared/_Layout.cshtml | 2 +- .../chessboardjs/js/chessboard-1.0.0.js | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Aiursoft.ChessServer/Controllers/GamesController.cs b/src/Aiursoft.ChessServer/Controllers/GamesController.cs index 8954c92..6309318 100644 --- a/src/Aiursoft.ChessServer/Controllers/GamesController.cs +++ b/src/Aiursoft.ChessServer/Controllers/GamesController.cs @@ -55,7 +55,7 @@ public class GamesController : Controller } [Route("games/{id}/ws")] - public async Task GetWebSocket([FromRoute] int id) + public async Task GetWebSocket([FromRoute] int id) { var lastReadId = _counter.GetCurrent; var (channel, blocker) = _database.ListenChannel(id); @@ -84,7 +84,7 @@ public class GamesController : Controller } } - return NoContent(); + // System.InvalidOperationException: StatusCode cannot be set because the response has already started. } [Route("games/{id}/ascii")] diff --git a/src/Aiursoft.ChessServer/Middlewares/AllowCrossOriginMiddleware.cs b/src/Aiursoft.ChessServer/Middlewares/AllowCrossOriginMiddleware.cs index 719d641..031db18 100644 --- a/src/Aiursoft.ChessServer/Middlewares/AllowCrossOriginMiddleware.cs +++ b/src/Aiursoft.ChessServer/Middlewares/AllowCrossOriginMiddleware.cs @@ -23,7 +23,7 @@ context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); context.Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Accept, Authorization"); - if (context.Request.Method == "OPTIONS") + if (context.Request.Method == "OPTIONS" && !context.Response.HasStarted) { context.Response.StatusCode = 200; return; diff --git a/src/Aiursoft.ChessServer/Views/Games/GetHtml.cshtml b/src/Aiursoft.ChessServer/Views/Games/GetHtml.cshtml index 1afbc23..6f703d1 100644 --- a/src/Aiursoft.ChessServer/Views/Games/GetHtml.cshtml +++ b/src/Aiursoft.ChessServer/Views/Games/GetHtml.cshtml @@ -2,15 +2,31 @@ @section Styles { + } -
-

-

+@* Make a responsible board based on bootstrap: (Avoid width with hardcode or overflow) *@ +@*
*@ + +
+
+
+
+
+ @* Make the following p auto warp *@ + +

+ +
+
@section Scripts { - + - + @* *@ @await RenderSectionAsync("Scripts", required: false) diff --git a/src/Aiursoft.ChessServer/wwwroot/chessboardjs/js/chessboard-1.0.0.js b/src/Aiursoft.ChessServer/wwwroot/chessboardjs/js/chessboard-1.0.0.js index ab613bd..92e9b49 100644 --- a/src/Aiursoft.ChessServer/wwwroot/chessboardjs/js/chessboard-1.0.0.js +++ b/src/Aiursoft.ChessServer/wwwroot/chessboardjs/js/chessboard-1.0.0.js @@ -1655,7 +1655,7 @@ if (!isDragging) return // prevent screen from scrolling - evt.preventDefault() + //evt.preventDefault() updateDraggedPiece(evt.originalEvent.changedTouches[0].pageX, evt.originalEvent.changedTouches[0].pageY)