From e5ddc46deb888f2a13f4a15e55589cb16632079c Mon Sep 17 00:00:00 2001 From: rmbgame Date: Thu, 6 May 2021 15:21:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=A6=E5=8F=B7=E5=88=87?= =?UTF-8?q?=E6=8D=A2ui=E9=94=99=E4=BD=8D=E9=97=AE=E9=A2=98=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=B4=A6=E5=8F=B7=E5=88=87=E6=8D=A2=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=20=E6=B7=BB=E5=8A=A0=E5=85=B3=E4=BA=8E?= =?UTF-8?q?=E5=86=85=E6=89=8B=E5=8A=A8=E6=9B=B4=E6=96=B0=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E6=9B=B4=E6=96=B0=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E4=B8=BA=E4=B8=8D=E7=BB=91=E5=AE=9A=E7=88=B6=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../App.axaml.cs | 6 +- .../Services/IDesktopAvaloniaAppService.cs | 8 ++- .../AvaloniaDesktopAppUpdateServiceImpl.cs | 2 +- .../Implementation/ShowWindowServiceImpl.cs | 20 ++++-- .../Pages/About/About_SoftwarePage.axaml | 4 ++ .../UI/Views/Pages/SteamAccountPage.axaml | 29 ++++---- .../ST.Client.Desktop.Avalonia.csproj | 22 ++---- .../Services/IShowWindowService.cs | 8 ++- .../Implementation/SteamServiceImpl.cs | 2 +- .../UI/Resx/AppResources.Designer.cs | 11 ++- .../UI/Resx/AppResources.resx | 5 +- .../UI/ViewModels/Base/TabItemViewModel.cs | 2 +- .../UI/ViewModels/MainWindowViewModel.cs | 2 +- .../Pages/About/AboutPageViewModel.cs | 6 ++ .../Pages/CommunityProxyPageViewModel.cs | 2 +- .../Pages/ProxyScriptManagePageViewModel.cs | 3 +- .../Implementation/HttpProxyServiceImpl.cs | 70 +++++++++---------- 17 files changed, 112 insertions(+), 90 deletions(-) diff --git a/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs b/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs index 7c3da864b..b92d25c06 100644 --- a/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs @@ -394,9 +394,9 @@ namespace System.Application.UI mainWindow.ActivateWorkaround(); // Extension method hack because of https://github.com/AvaloniaUI/Avalonia/issues/2975 mainWindow.Focus(); - // Again, ugly hack because of https://github.com/AvaloniaUI/Avalonia/issues/2994 - mainWindow.Width += 0.1; - mainWindow.Width -= 0.1; + //// Again, ugly hack because of https://github.com/AvaloniaUI/Avalonia/issues/2994 + //mainWindow.Width += 0.1; + //mainWindow.Width -= 0.1; } public bool HasActiveWindow() diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/IDesktopAvaloniaAppService.cs b/src/ST.Client.Desktop.Avalonia/Application/Services/IDesktopAvaloniaAppService.cs index 9fb65dd73..e6eae1d83 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/IDesktopAvaloniaAppService.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/Services/IDesktopAvaloniaAppService.cs @@ -1,4 +1,4 @@ -using Avalonia.Controls; +using Avalonia.Controls; using System.Threading.Tasks; using AvaloniaApplication = Avalonia.Application; @@ -30,5 +30,11 @@ namespace System.Application.Services var owner = GetActiveWindow(); window.Show(owner); } + + void ShowWindowNoParent(Window window) + { + var owner = GetActiveWindow(); + window.Show(); + } } } \ No newline at end of file diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/AvaloniaDesktopAppUpdateServiceImpl.cs b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/AvaloniaDesktopAppUpdateServiceImpl.cs index 6e3eb1bb4..4515f2033 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/AvaloniaDesktopAppUpdateServiceImpl.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/AvaloniaDesktopAppUpdateServiceImpl.cs @@ -20,7 +20,7 @@ namespace System.Application.Services.Implementation var hasActiveWindow = IDesktopAppService.Instance.HasActiveWindow(); if (hasActiveWindow) { - await IShowWindowService.Instance.Show(typeof(object), CustomWindow.NewVersion); + await IShowWindowService.Instance.Show(typeof(object), CustomWindow.NewVersion, isParent: false); } } diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs index ed13f138e..9fa406451 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs @@ -1,4 +1,4 @@ -using Avalonia.Controls; +using Avalonia.Controls; using ReactiveUI; using System.Application.UI.ViewModels; using System.Threading.Tasks; @@ -31,6 +31,7 @@ namespace System.Application.Services.Implementation string title, WindowViewModel? viewModel, ResizeModeCompat resizeMode, + bool isParent = true, Action? actionDialogWindowViewModel = null) => MainThreadDesktop.InvokeOnMainThreadAsync(async () => { @@ -97,7 +98,10 @@ namespace System.Application.Services.Implementation } else { - IDesktopAvaloniaAppService.Instance.ShowWindow(window); + if (isParent) + IDesktopAvaloniaAppService.Instance.ShowWindow(window); + else + IDesktopAvaloniaAppService.Instance.ShowWindowNoParent(window); } }); @@ -106,17 +110,19 @@ namespace System.Application.Services.Implementation TWindowViewModel? viewModel = null, string title = "", ResizeModeCompat resizeMode = ResizeModeCompat.NoResize, - bool isDialog = false) + bool isDialog = false, + bool isParent = true) where TWindowViewModel : WindowViewModel, new() => Show(typeof(TWindowViewModel), - customWindow, viewModel, title, resizeMode, isDialog); + customWindow, viewModel, title, resizeMode, isDialog, isParent); public Task Show(Type typeWindowViewModel, CustomWindow customWindow, WindowViewModel? viewModel = null, string title = "", ResizeModeCompat resizeMode = ResizeModeCompat.NoResize, - bool isDialog = false) => Show(typeWindowViewModel, isDialog, customWindow, - title, viewModel, resizeMode); + bool isDialog = false, + bool isParent = true) => Show(typeWindowViewModel, isDialog, customWindow, + title, viewModel, resizeMode, isParent); public async Task ShowDialog( CustomWindow customWindow, @@ -128,7 +134,7 @@ namespace System.Application.Services.Implementation { DialogWindowViewModel? dialogWindowViewModel = null; await Show(typeof(TWindowViewModel), isDialog, customWindow, - title, viewModel, resizeMode, dwvm => + title, viewModel, resizeMode, true, dwvm => { dialogWindowViewModel = dwvm; }); diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/About/About_SoftwarePage.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/About/About_SoftwarePage.axaml index 062a9113c..514931d22 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/About/About_SoftwarePage.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/About/About_SoftwarePage.axaml @@ -94,6 +94,10 @@ VerticalAlignment="Center"/> + - - - + + + + + + + + - @@ -97,11 +97,10 @@ - - + - + diff --git a/src/ST.Client.Desktop.Avalonia/ST.Client.Desktop.Avalonia.csproj b/src/ST.Client.Desktop.Avalonia/ST.Client.Desktop.Avalonia.csproj index 51194b90b..a15904ec4 100644 --- a/src/ST.Client.Desktop.Avalonia/ST.Client.Desktop.Avalonia.csproj +++ b/src/ST.Client.Desktop.Avalonia/ST.Client.Desktop.Avalonia.csproj @@ -41,28 +41,16 @@ - - - - + + + + - - - - - - About_SoftwarePage.axaml - - - Settings_General.axaml - - - EditAppInfoWindow.axaml - + \ No newline at end of file diff --git a/src/ST.Client.Desktop/Services/IShowWindowService.cs b/src/ST.Client.Desktop/Services/IShowWindowService.cs index d9369e9c8..ab310cf75 100644 --- a/src/ST.Client.Desktop/Services/IShowWindowService.cs +++ b/src/ST.Client.Desktop/Services/IShowWindowService.cs @@ -1,4 +1,4 @@ -using System.Application.UI.ViewModels; +using System.Application.UI.ViewModels; using System.Threading.Tasks; using System.Windows; @@ -26,7 +26,8 @@ namespace System.Application.Services TWindowViewModel? viewModel = null, string title = "", ResizeModeCompat resizeMode = ResizeModeCompat.NoResize, - bool isDialog = false) + bool isDialog = false, + bool isParent = true) where TWindowViewModel : WindowViewModel, new(); /// @@ -35,7 +36,8 @@ namespace System.Application.Services WindowViewModel? viewModel = null, string title = "", ResizeModeCompat resizeMode = ResizeModeCompat.NoResize, - bool isDialog = false); + bool isDialog = false, + bool isParent = true); /// /// 显示一个弹窗,返回 确定(仅当ViewModel继承自时生效), 取消 diff --git a/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs b/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs index 4f0d466a1..1495ad33b 100644 --- a/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs +++ b/src/ST.Client.Desktop/Services/Implementation/SteamServiceImpl.cs @@ -64,7 +64,7 @@ namespace System.Application.Services.Implementation { get { - return Process.GetProcessesByName(steamProcess[0])?.Length > 0; + return Process.GetProcessesByName(steamProcess[0]).Any_Nullable(); } } diff --git a/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs b/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs index c4f22d9ab..b6ead7fe0 100644 --- a/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs +++ b/src/ST.Client.Desktop/UI/Resx/AppResources.Designer.cs @@ -413,6 +413,15 @@ namespace System.Application.UI.Resx { } } + /// + /// 查找类似 检查更新 的本地化字符串。 + /// + public static string CheckUpdate { + get { + return ResourceManager.GetString("CheckUpdate", resourceCulture); + } + } + /// /// 查找类似 云同步 的本地化字符串。 /// @@ -2017,7 +2026,7 @@ namespace System.Application.UI.Resx { } /// - /// 查找类似 基本设置 的本地化字符串。 + /// 查找类似 通用设置 的本地化字符串。 /// public static string Settings_General { get { diff --git a/src/ST.Client.Desktop/UI/Resx/AppResources.resx b/src/ST.Client.Desktop/UI/Resx/AppResources.resx index 2de95aaf7..fe688ce09 100644 --- a/src/ST.Client.Desktop/UI/Resx/AppResources.resx +++ b/src/ST.Client.Desktop/UI/Resx/AppResources.resx @@ -236,6 +236,9 @@ 取消 + + 检查更新 + 云同步 @@ -776,7 +779,7 @@ 字体 - 基本设置 + 通用设置 启动时自动检查更新 diff --git a/src/ST.Client.Desktop/UI/ViewModels/Base/TabItemViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Base/TabItemViewModel.cs index cf05ca4bd..17672c173 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Base/TabItemViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Base/TabItemViewModel.cs @@ -1,4 +1,4 @@ -using ReactiveUI; +using ReactiveUI; using StatefulModel.EventListeners; using System.Application.UI.Resx; using System.Collections.Generic; diff --git a/src/ST.Client.Desktop/UI/ViewModels/MainWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/MainWindowViewModel.cs index 2b6892059..bfe0d61eb 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/MainWindowViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/MainWindowViewModel.cs @@ -77,7 +77,7 @@ namespace System.Application.UI.ViewModels AddTabItem(); //AddTabItem(); //AddTabItem(); - //AddTabItem(); + AddTabItem(); //AddTabItem(); AddTabItem(() => SettingsPageViewModel.Instance); diff --git a/src/ST.Client.Desktop/UI/ViewModels/Pages/About/AboutPageViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Pages/About/AboutPageViewModel.cs index 6467a2049..431f48deb 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Pages/About/AboutPageViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Pages/About/AboutPageViewModel.cs @@ -24,7 +24,13 @@ namespace System.Application.UI.ViewModels OpenBrowserCommand = ReactiveCommand.Create(BrowserOpen); CopyLinkCommand = ReactiveCommand.Create(IDesktopAppService.Instance.SetClipboardText); + + CheckUpdateCommand = ReactiveCommand.Create(() => + { + IAppUpdateService.Instance.CheckUpdate(showIsExistUpdateFalse: true); + }); } + public ReactiveCommand CheckUpdateCommand { get; } public ReactiveCommand OpenBrowserCommand { get; } diff --git a/src/ST.Client.Desktop/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs index 0b3fb0e63..bed630185 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs @@ -27,7 +27,7 @@ namespace System.Application.UI.ViewModels public ReactiveCommand OpenCertificateDirCommand { get; } public ReactiveCommand EditHostsFileCommand { get; } public ReactiveCommand AutoRunProxyCommand { get; } - public ReactiveCommand EnableProxyScriptCommand { get; } + //public ReactiveCommand EnableProxyScriptCommand { get; } public MenuItemViewModel AutoRunProxy { get; } //public MenuItemViewModel EnableProxyScript { get; } diff --git a/src/ST.Client.Desktop/UI/ViewModels/Pages/ProxyScriptManagePageViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Pages/ProxyScriptManagePageViewModel.cs index 1bf0b9494..6c745609d 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Pages/ProxyScriptManagePageViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Pages/ProxyScriptManagePageViewModel.cs @@ -25,7 +25,6 @@ namespace System.Application.UI.ViewModels internal override void Activation() { - if (IsFirstActivation) if (ProxySettings.IsAutoCheckScriptUpdate) ProxyService.Current.CheckUpdate(); @@ -184,7 +183,7 @@ namespace System.Application.UI.ViewModels } else { - DeleteNoFileScriptItemButton(script); + DeleteNoFileScriptItemButton(script); } } diff --git a/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs b/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs index a85f033d5..2d8b9db13 100644 --- a/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs +++ b/src/ST.Client/Services/Implementation/HttpProxyServiceImpl.cs @@ -399,43 +399,48 @@ namespace System.Application.Services.Implementation //proxyServer.ServerCertificateValidationCallback += OnCertificateValidation; //proxyServer.ClientCertificateSelectionCallback += OnCertificateSelection; - - var explicitProxyEndPoint = new ExplicitProxyEndPoint(ProxyIp, GetRandomUnusedPort(), true) + try { - // 通过不启用为每个http的域创建证书来优化性能 - //GenericCertificate = proxyServer.CertificateManager.RootCertificate - }; - - if (IsWindowsProxy) - { - //explicit endpoint 是客户端知道代理存在的地方 - proxyServer.AddEndPoint(explicitProxyEndPoint); - } - else - { - //if (PortInUse(443)) - //{ - // return false; - //} - - proxyServer.AddEndPoint(new TransparentProxyEndPoint(ProxyIp, 443, true) + var explicitProxyEndPoint = new ExplicitProxyEndPoint(ProxyIp, GetRandomUnusedPort(), true) { // 通过不启用为每个http的域创建证书来优化性能 //GenericCertificate = proxyServer.CertificateManager.RootCertificate + }; + + if (IsWindowsProxy) + { + //explicit endpoint 是客户端知道代理存在的地方 + proxyServer.AddEndPoint(explicitProxyEndPoint); + } + else + { + //if (PortInUse(443)) + //{ + // return false; + //} + + proxyServer.AddEndPoint(new TransparentProxyEndPoint(ProxyIp, 443, true) + { + // 通过不启用为每个http的域创建证书来优化性能 + //GenericCertificate = proxyServer.CertificateManager.RootCertificate + }); + + if (PortInUse(80) == false) + proxyServer.AddEndPoint(new TransparentProxyEndPoint(ProxyIp, 80, false)); + } + + proxyServer.ExceptionFunc = ((Exception exception) => + { + Log.Error("Proxy", exception, "ProxyServer ExceptionFunc"); }); - if (PortInUse(80) == false) - proxyServer.AddEndPoint(new TransparentProxyEndPoint(ProxyIp, 80, false)); - } - - proxyServer.ExceptionFunc = ((Exception exception) => - { - Log.Error("Proxy", exception, "ProxyServer ExceptionFunc"); - }); - - try - { proxyServer.Start(); + + if (IsWindowsProxy) + { + proxyServer.SetAsSystemHttpProxy(explicitProxyEndPoint); + proxyServer.SetAsSystemHttpsProxy(explicitProxyEndPoint); + } } catch (Exception ex) { @@ -443,11 +448,6 @@ namespace System.Application.Services.Implementation return false; } - if (IsWindowsProxy) - { - proxyServer.SetAsSystemHttpProxy(explicitProxyEndPoint); - proxyServer.SetAsSystemHttpsProxy(explicitProxyEndPoint); - } #endregion #if DEBUG foreach (var endPoint in proxyServer.ProxyEndPoints)