fix: proxy default protocol / start location (#4100)

fix #4096
This commit is contained in:
MistEO
2023-03-28 21:57:32 +08:00
committed by GitHub
2 changed files with 15 additions and 4 deletions

View File

@@ -16,6 +16,7 @@ using System.Globalization;
using System.Linq;
using System.Windows;
using MaaWpfGui.Constants;
using MaaWpfGui.Views.UI;
using Stylet;
using Screen = System.Windows.Forms.Screen;
@@ -38,8 +39,6 @@ namespace MaaWpfGui.Helper
private readonly double Width = double.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.WindowWidth, DefaultDouble.ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture);
private readonly double Height = double.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.WindowHeight, DefaultDouble.ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture);
private readonly string RootView = "MaaWpfGui.RootView";
public void MoveWindowToDisplay(string displayName, Window window)
{
var screen = Screen.AllScreens.FirstOrDefault(x => x.DeviceName == displayName);
@@ -73,7 +72,7 @@ namespace MaaWpfGui.Helper
// In Stylet, CreateWindow().WindowStartupLocation is CenterScreen or CenterOwner (if w.WSLoc == Manual && w.Left == NaN && w.Top == NaN && ...)
window.WindowStartupLocation = WindowStartupLocation.Manual;
if (window.ToString() == RootView)
if (window is RootView)
{
MoveWindowToDisplay(ScreenName, window);
}

View File

@@ -31,7 +31,19 @@ namespace MaaWpfGui.Services.Web
{
private const string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 Edg/97.0.1072.76";
private static string Proxy => ConfigurationHelper.GetValue(ConfigurationKeys.UpdateProxy, string.Empty);
private static string Proxy
{
get
{
var p = ConfigurationHelper.GetValue(ConfigurationKeys.UpdateProxy, string.Empty);
if (string.IsNullOrEmpty(p))
{
return string.Empty;
}
return p.Contains("://") ? p : $"http://{p}";
}
}
private readonly ILogger _logger = Log.ForContext<HttpService>();