简化WEB库

This commit is contained in:
2025-09-23 10:38:35 +08:00
parent 9a89a138dd
commit c6037c51ed
17 changed files with 165 additions and 780 deletions

View File

@@ -122,7 +122,10 @@ namespace 电子展板.ViewModels
/// </summary>
public void WindowClosing(CancelEventArgs args)
{
WebServer.Stop();
GlobalVariable.WebServer?.Stop();
GlobalVariable.WebServer?.Dispose();
GlobalVariable.WebServer = null;
Screen[] screens = Screen.AllScreens;
if (screens.Length > 1)
{

View File

@@ -1,4 +1,7 @@
using System;
using Nancy;
using Nancy.Hosting.Self;
using Nancy.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
@@ -30,12 +33,15 @@ namespace 电子展板.ViewModels
this.window.Top = (int)(Screen.AllScreens[screenIndex].Bounds.Top / GetDpiScaleX());
this.window.Width = (int)(Screen.AllScreens[screenIndex].Bounds.Width / GetDpiScaleX());
this.window.Height = (int)(Screen.AllScreens[screenIndex].Bounds.Height / GetDpiScaleX());
WebServer.Start();
GlobalVariable.WebServer = new NancyHost(new Uri("http://localhost:80"));
GlobalVariable.WebServer.Start();
}
private void WindowClosing(CancelEventArgs args)
{
WebServer.Stop();
GlobalVariable.WebServer?.Stop();
GlobalVariable.WebServer?.Dispose();
GlobalVariable.WebServer = null;
Environment.Exit(0);
}
public double GetDpiScaleX()