From 31655bf8903dbbc4b8ca8011ed48302ffa2947f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E4=B9=9D?= <366193849@qq.com> Date: Thu, 28 Oct 2021 22:15:29 +0800 Subject: [PATCH] fix bug --- Directory.Build.props | 3 +- FastGithub.FlowAnalyze/FlowAnalyzer.cs | 19 ++++++- .../FastGithub.HttpServer.csproj | 2 +- .../KestrelServerOptionsExtensions.cs | 5 +- FastGithub.UI/App.xaml.cs | 13 ++++- FastGithub.UI/FastGithub.UI.csproj | 3 +- FastGithub.UI/MainWindow.xaml | 6 +- .../Properties/Resources.Designer.cs | 56 ++++++++----------- FastGithub.UI/Properties/Settings.Designer.cs | 30 +++++----- FastGithub/FastGithub.csproj | 7 +-- 10 files changed, 81 insertions(+), 63 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index cd010cb..b905fe7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,8 @@ 2.0.5 net6.0 - true + true + true true github加速神器 https://github.com/dotnetcore/FastGithub diff --git a/FastGithub.FlowAnalyze/FlowAnalyzer.cs b/FastGithub.FlowAnalyze/FlowAnalyzer.cs index 793c558..dfaa282 100644 --- a/FastGithub.FlowAnalyze/FlowAnalyzer.cs +++ b/FastGithub.FlowAnalyze/FlowAnalyzer.cs @@ -30,6 +30,17 @@ namespace FastGithub.FlowAnalyze } private static void Add(ConcurrentQueue quques, int length) + { + var ticks = Flush(quques); + quques.Enqueue(new QueueItem(ticks, length)); + } + + /// + /// 刷新队列 + /// + /// + /// + private static long Flush(ConcurrentQueue quques) { var ticks = Environment.TickCount64; while (quques.TryPeek(out var item)) @@ -43,17 +54,23 @@ namespace FastGithub.FlowAnalyze quques.TryDequeue(out _); } } - quques.Enqueue(new QueueItem(ticks, length)); + return ticks; } + + /// /// 获取速率 /// /// public FlowRate GetFlowRate() { + Flush(this.readQueue); var readRate = (double)this.readQueue.Sum(item => item.Length) / INTERVAL_SECONDS; + + Flush(this.writeQueue); var writeRate = (double)this.writeQueue.Sum(item => item.Length) / INTERVAL_SECONDS; + return new FlowRate { ReadRate = readRate, WriteRate = writeRate }; } } diff --git a/FastGithub.HttpServer/FastGithub.HttpServer.csproj b/FastGithub.HttpServer/FastGithub.HttpServer.csproj index ba78119..538e2cf 100644 --- a/FastGithub.HttpServer/FastGithub.HttpServer.csproj +++ b/FastGithub.HttpServer/FastGithub.HttpServer.csproj @@ -1,7 +1,7 @@  - enable + enable true diff --git a/FastGithub.HttpServer/KestrelServerOptionsExtensions.cs b/FastGithub.HttpServer/KestrelServerOptionsExtensions.cs index a7f2898..56bd15c 100644 --- a/FastGithub.HttpServer/KestrelServerOptionsExtensions.cs +++ b/FastGithub.HttpServer/KestrelServerOptionsExtensions.cs @@ -93,7 +93,10 @@ namespace FastGithub var httpsPort = ReverseProxyPort.Https; kestrel.Listen(IPAddress.Loopback, httpsPort, listen => { - listen.UseFlowAnalyze(); + if (OperatingSystem.IsWindows()) + { + listen.UseFlowAnalyze(); + } listen.UseHttps(https => { https.ServerCertificateSelector = (ctx, domain) => certService.GetOrCreateServerCert(domain); diff --git a/FastGithub.UI/App.xaml.cs b/FastGithub.UI/App.xaml.cs index 710f336..28caba8 100644 --- a/FastGithub.UI/App.xaml.cs +++ b/FastGithub.UI/App.xaml.cs @@ -1,4 +1,6 @@ -using System.Windows; +using Microsoft.Win32; +using System.Diagnostics; +using System.Windows; namespace FastGithub.UI { @@ -6,6 +8,13 @@ namespace FastGithub.UI /// App.xaml 的交互逻辑 /// public partial class App : Application - { + { + protected override void OnStartup(StartupEventArgs e) + { + var emulation = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true); + var key = $"{Process.GetCurrentProcess().ProcessName}.exe"; + emulation.SetValue(key, 9000, RegistryValueKind.DWord); + base.OnStartup(e); + } } } diff --git a/FastGithub.UI/FastGithub.UI.csproj b/FastGithub.UI/FastGithub.UI.csproj index fad9374..3b10cb3 100644 --- a/FastGithub.UI/FastGithub.UI.csproj +++ b/FastGithub.UI/FastGithub.UI.csproj @@ -8,12 +8,13 @@ WinExe FastGithub.UI FastGithub.UI - v4.5.1 + v4.5 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 true true + AnyCPU diff --git a/FastGithub.UI/MainWindow.xaml b/FastGithub.UI/MainWindow.xaml index 1400cd9..78c4bd7 100644 --- a/FastGithub.UI/MainWindow.xaml +++ b/FastGithub.UI/MainWindow.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:FastGithub.UI" mc:Ignorable="d" - Title="FastGithub" Height="640" Width="960" WindowStartupLocation="CenterScreen"> + Title="FastGithub" Height="480" Width="640" WindowStartupLocation="CenterScreen"> @@ -92,7 +92,8 @@ - + + @@ -129,6 +130,7 @@ + diff --git a/FastGithub.UI/Properties/Resources.Designer.cs b/FastGithub.UI/Properties/Resources.Designer.cs index 4b5e044..96f9f61 100644 --- a/FastGithub.UI/Properties/Resources.Designer.cs +++ b/FastGithub.UI/Properties/Resources.Designer.cs @@ -1,69 +1,61 @@ //------------------------------------------------------------------------------ // // 此代码由工具生成。 -// 运行时版本: 4.0.30319.42000 +// 运行时版本:4.0.30319.42000 // -// 对此文件的更改可能导致不正确的行为,如果 -// 重新生成代码,则所做更改将丢失。 +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ -namespace FastGithub.UI.Properties -{ - - +namespace FastGithub.UI.Properties { + using System; + + /// - /// 强类型资源类,用于查找本地化字符串等。 + /// 一个强类型的资源类,用于查找本地化的字符串等。 /// // 此类是由 StronglyTypedResourceBuilder // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// - /// 返回此类使用的缓存 ResourceManager 实例。 + /// 返回此类使用的缓存的 ResourceManager 实例。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FastGithub.UI.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// 重写当前线程的 CurrentUICulture 属性,对 /// 使用此强类型资源类的所有资源查找执行重写。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/FastGithub.UI/Properties/Settings.Designer.cs b/FastGithub.UI/Properties/Settings.Designer.cs index e29656b..e4e4809 100644 --- a/FastGithub.UI/Properties/Settings.Designer.cs +++ b/FastGithub.UI/Properties/Settings.Designer.cs @@ -1,28 +1,24 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ -namespace FastGithub.UI.Properties -{ - - +namespace FastGithub.UI.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/FastGithub/FastGithub.csproj b/FastGithub/FastGithub.csproj index be6b20f..9ad58f1 100644 --- a/FastGithub/FastGithub.csproj +++ b/FastGithub/FastGithub.csproj @@ -45,12 +45,9 @@ - + PreserveNewest - - - PreserveNewest - +