老九 3 years ago
parent
commit
31655bf890

+ 2 - 1
Directory.Build.props

@@ -2,7 +2,8 @@
 	<PropertyGroup>
 		<Version>2.0.5</Version>	
 		<TargetFramework>net6.0</TargetFramework>	
-		 <IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled> 
+		<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
+		<IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled> 
 		<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>		
 		<Description>github加速神器</Description>
 		<Copyright>https://github.com/dotnetcore/FastGithub</Copyright>

+ 18 - 1
FastGithub.FlowAnalyze/FlowAnalyzer.cs

@@ -30,6 +30,17 @@ namespace FastGithub.FlowAnalyze
         }
 
         private static void Add(ConcurrentQueue<QueueItem> quques, int length)
+        {
+            var ticks = Flush(quques);
+            quques.Enqueue(new QueueItem(ticks, length));
+        }
+
+        /// <summary>
+        /// 刷新队列
+        /// </summary>
+        /// <param name="quques"></param>
+        /// <returns></returns>
+        private static long Flush(ConcurrentQueue<QueueItem> 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;
         }
 
+
+
         /// <summary>
         /// 获取速率
         /// </summary>
         /// <returns></returns>
         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 };
         }
     }

+ 1 - 1
FastGithub.HttpServer/FastGithub.HttpServer.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
 	<PropertyGroup>
-    <Nullable>enable</Nullable>
+		<Nullable>enable</Nullable>
 		<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
 	</PropertyGroup>
 

+ 4 - 1
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);

+ 11 - 2
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 的交互逻辑
     /// </summary>
     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);
+        }
     }
 }

+ 2 - 1
FastGithub.UI/FastGithub.UI.csproj

@@ -8,12 +8,13 @@
     <OutputType>WinExe</OutputType>
     <RootNamespace>FastGithub.UI</RootNamespace>
     <AssemblyName>FastGithub.UI</AssemblyName>
-    <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <WarningLevel>4</WarningLevel>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <Deterministic>true</Deterministic>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>

+ 4 - 2
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">
 
     <Window.Resources>
         <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
@@ -92,7 +92,8 @@
                                         <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                         <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Top"/>
                                     </MultiDataTrigger.Conditions>
-
+                                    
+                                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                                     <Setter Property="Foreground" TargetName="txt" Value="#37aefe"/>
                                 </MultiDataTrigger>
                                 <MultiDataTrigger>
@@ -129,6 +130,7 @@
                                         <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                         <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type TabControl}}}" Value="Top"/>
                                     </MultiDataTrigger.Conditions>
+                                    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                                     <Setter Property="Panel.ZIndex" Value="1"/>
                                     <Setter Property="Foreground" TargetName="txt" Value="#37aefe"/>
                                     <Setter Property="BorderThickness" TargetName="_underline" Value="0 0 0 2"/>

+ 24 - 32
FastGithub.UI/Properties/Resources.Designer.cs

@@ -1,69 +1,61 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
-//     运行时版本: 4.0.30319.42000
+//     运行时版本:4.0.30319.42000
 //
-//     对此文件的更改可能导致不正确的行为,如果
-//     重新生成代码,则所做更改将丢失。
+//     对此文件的更改可能导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace FastGithub.UI.Properties
-{
-
-
+namespace FastGithub.UI.Properties {
+    using System;
+    
+    
     /// <summary>
-    ///   强类型资源类,用于查找本地化字符串等。
+    ///   一个强类型资源类,用于查找本地化字符串等。
     /// </summary>
     // 此类是由 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() {
         }
-
+        
         /// <summary>
-        ///   返回此类使用的缓存 ResourceManager 实例。
+        ///   返回此类使用的缓存 ResourceManager 实例。
         /// </summary>
         [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;
             }
         }
-
+        
         /// <summary>
         ///   重写当前线程的 CurrentUICulture 属性,对
         ///   使用此强类型资源类的所有资源查找执行重写。
         /// </summary>
         [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;
             }
         }

+ 13 - 17
FastGithub.UI/Properties/Settings.Designer.cs

@@ -1,28 +1,24 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
-//     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.
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-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;
             }
         }

+ 2 - 5
FastGithub/FastGithub.csproj

@@ -45,12 +45,9 @@
   </ItemGroup>
 
   <ItemGroup>
-    <Content Update="wwwroot\flow.html">
+    <Content Update="wwwroot\**">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Update="wwwroot\cert.html">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
+    </Content> 
   </ItemGroup>
 
 </Project>