From df017ed29c7bb6b53ab26698fe13f9f3c04a507f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Mon, 1 Nov 2021 13:36:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.FlowAnalyze/FlowAnalyzer.cs | 6 +++--- .../{FlowRate.cs => FlowStatistics.cs} | 11 ++++++++++- FastGithub.FlowAnalyze/IFlowAnalyzer.cs | 2 +- FastGithub.UI/FastGithub.UI.csproj | 2 +- FastGithub.UI/FlowChart.xaml.cs | 18 +++++++++--------- .../{FlowRate.cs => FlowStatistics.cs} | 15 ++++++++++++--- FastGithub/Startup.cs | 6 +++--- README.html | 6 ++---- README.md | 6 ++---- 9 files changed, 43 insertions(+), 29 deletions(-) rename FastGithub.FlowAnalyze/{FlowRate.cs => FlowStatistics.cs} (61%) rename FastGithub.UI/{FlowRate.cs => FlowStatistics.cs} (69%) diff --git a/FastGithub.FlowAnalyze/FlowAnalyzer.cs b/FastGithub.FlowAnalyze/FlowAnalyzer.cs index e4c9c1b..6fee15b 100644 --- a/FastGithub.FlowAnalyze/FlowAnalyzer.cs +++ b/FastGithub.FlowAnalyze/FlowAnalyzer.cs @@ -65,10 +65,10 @@ namespace FastGithub.FlowAnalyze /// - /// 获取速率 + /// 获取流量分析 /// /// - public FlowRate GetFlowRate() + public FlowStatistics GetFlowStatistics() { Flush(this.readQueue); var readRate = (double)this.readQueue.Sum(item => item.Length) / INTERVAL_SECONDS; @@ -76,7 +76,7 @@ namespace FastGithub.FlowAnalyze Flush(this.writeQueue); var writeRate = (double)this.writeQueue.Sum(item => item.Length) / INTERVAL_SECONDS; - return new FlowRate + return new FlowStatistics { TotalRead = this.totalRead, TotalWrite = this.totalWrite, diff --git a/FastGithub.FlowAnalyze/FlowRate.cs b/FastGithub.FlowAnalyze/FlowStatistics.cs similarity index 61% rename from FastGithub.FlowAnalyze/FlowRate.cs rename to FastGithub.FlowAnalyze/FlowStatistics.cs index 536a2c2..cab0a16 100644 --- a/FastGithub.FlowAnalyze/FlowRate.cs +++ b/FastGithub.FlowAnalyze/FlowStatistics.cs @@ -1,6 +1,9 @@ namespace FastGithub.FlowAnalyze { - public record FlowRate + /// + /// 流量统计 + /// + public record FlowStatistics { /// /// 获取总读上行 @@ -12,8 +15,14 @@ /// public long TotalWrite { get; init; } + /// + /// 获取读取速率 + /// public double ReadRate { get; init; } + /// + /// 获取写入速率 + /// public double WriteRate { get; init; } } } diff --git a/FastGithub.FlowAnalyze/IFlowAnalyzer.cs b/FastGithub.FlowAnalyze/IFlowAnalyzer.cs index cfa2537..809969a 100644 --- a/FastGithub.FlowAnalyze/IFlowAnalyzer.cs +++ b/FastGithub.FlowAnalyze/IFlowAnalyzer.cs @@ -16,6 +16,6 @@ /// 获取速率 /// /// - FlowRate GetFlowRate(); + FlowStatistics GetFlowStatistics(); } } diff --git a/FastGithub.UI/FastGithub.UI.csproj b/FastGithub.UI/FastGithub.UI.csproj index 9e4c00f..d13fa68 100644 --- a/FastGithub.UI/FastGithub.UI.csproj +++ b/FastGithub.UI/FastGithub.UI.csproj @@ -88,7 +88,7 @@ App.xaml Code - + FlowChart.xaml diff --git a/FastGithub.UI/FlowChart.xaml.cs b/FastGithub.UI/FlowChart.xaml.cs index 3fb8bc7..6052e8d 100644 --- a/FastGithub.UI/FlowChart.xaml.cs +++ b/FastGithub.UI/FlowChart.xaml.cs @@ -31,7 +31,7 @@ namespace FastGithub.UI public List Labels { get; } = new List(); - public Func YFormatter { get; } = value => $"{FlowRate.ToNetworkSizeString((long)value)}/s"; + public Func YFormatter { get; } = value => $"{FlowStatistics.ToNetworkSizeString((long)value)}/s"; public FlowChart() { @@ -51,7 +51,7 @@ namespace FastGithub.UI { try { - await this.GetFlowRateAsync(httpClient); + await this.GetFlowStatisticsAsync(httpClient); } catch (Exception) { @@ -63,17 +63,17 @@ namespace FastGithub.UI } } - private async Task GetFlowRateAsync(HttpClient httpClient) + private async Task GetFlowStatisticsAsync(HttpClient httpClient) { - var response = await httpClient.GetAsync("http://127.0.0.1/flowRates"); + var response = await httpClient.GetAsync("http://127.0.0.1/flowStatistics"); var json = await response.EnsureSuccessStatusCode().Content.ReadAsStringAsync(); - var flowRate = Newtonsoft.Json.JsonConvert.DeserializeObject(json); + var flowStatistics = Newtonsoft.Json.JsonConvert.DeserializeObject(json); - this.textBlockRead.Text = FlowRate.ToNetworkSizeString(flowRate.TotalRead); - this.textBlockWrite.Text = FlowRate.ToNetworkSizeString(flowRate.TotalWrite); + this.textBlockRead.Text = FlowStatistics.ToNetworkSizeString(flowStatistics.TotalRead); + this.textBlockWrite.Text = FlowStatistics.ToNetworkSizeString(flowStatistics.TotalWrite); - this.readSeries.Values.Add(flowRate.ReadRate); - this.writeSeries.Values.Add(flowRate.WriteRate); + this.readSeries.Values.Add(flowStatistics.ReadRate); + this.writeSeries.Values.Add(flowStatistics.WriteRate); this.Labels.Add(DateTime.Now.ToString("HH:mm:ss")); if (this.Labels.Count > 60) diff --git a/FastGithub.UI/FlowRate.cs b/FastGithub.UI/FlowStatistics.cs similarity index 69% rename from FastGithub.UI/FlowRate.cs rename to FastGithub.UI/FlowStatistics.cs index df1cf14..97f20ee 100644 --- a/FastGithub.UI/FlowRate.cs +++ b/FastGithub.UI/FlowStatistics.cs @@ -1,6 +1,9 @@ namespace FastGithub.UI { - public class FlowRate + /// + /// 流量统计 + /// + public class FlowStatistics { /// /// 获取总读上行 @@ -12,10 +15,16 @@ /// public long TotalWrite { get; set; } + /// + /// 获取上行速率 + /// public double ReadRate { get; set; } - public double WriteRate { get; set; } - + /// + /// 获取下行速率 + /// + public double WriteRate { get; set; } + public static string ToNetworkSizeString(long value) { diff --git a/FastGithub/Startup.cs b/FastGithub/Startup.cs index ad097b9..2bfae71 100644 --- a/FastGithub/Startup.cs +++ b/FastGithub/Startup.cs @@ -68,15 +68,15 @@ namespace FastGithub appBuilder.UseRouting(); appBuilder.UseEndpoints(endpoint => { - endpoint.MapGet("/flowRates", context => + endpoint.MapGet("/flowStatistics", context => { var loggingFeature = context.Features.Get(); if (loggingFeature != null) { loggingFeature.Enable = false; } - var flowRate = context.RequestServices.GetRequiredService().GetFlowRate(); - return context.Response.WriteAsJsonAsync(flowRate); + var flowStatistics = context.RequestServices.GetRequiredService().GetFlowStatistics(); + return context.Response.WriteAsJsonAsync(flowStatistics); }); }); }); diff --git a/README.html b/README.html index dd92dc6..b11d695 100644 --- a/README.html +++ b/README.html @@ -376,9 +376,7 @@ code {

2 部署方式

2.1 windows-x64

    -
  • 双击运行fastgithub.exe程序
  • -
  • fastgithub.exe start // 以windows服务安装并启动
  • -
  • fastgithub.exe stop // 以windows服务卸载并删除
  • +
  • 双击运行FastGithub.UI.exe

2.2 linux-x64

    @@ -388,7 +386,7 @@ code {

2.3 macOS-x64

    -
  • 双击运行fastgithub程序
  • +
  • 双击运行fastgithub
  • 安装cacert/fastgithub.cer并设置信任
  • 设置系统自动代理为http://127.0.0.1:38457,或手动代理http/https为127.0.0.1:38457
  • 具体配置详情
  • diff --git a/README.md b/README.md index c2c118d..faec34a 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,7 @@ github加速神器,解决github打不开、用户头像无法加载、releases ### 2 部署方式 #### 2.1 windows-x64 -* 双击运行fastgithub.exe程序 -* `fastgithub.exe start` // 以windows服务安装并启动 -* `fastgithub.exe stop` // 以windows服务卸载并删除 +* 双击运行FastGithub.UI.exe #### 2.2 linux-x64 * 执行`./fastgithub` @@ -18,7 +16,7 @@ github加速神器,解决github打不开、用户头像无法加载、releases * 设置系统自动代理为`http://127.0.0.1:38457`,或手动代理http/https为`127.0.0.1:38457` #### 2.3 macOS-x64 -* 双击运行fastgithub程序 +* 双击运行fastgithub * 安装cacert/fastgithub.cer并设置信任 * 设置系统自动代理为`http://127.0.0.1:38457`,或手动代理http/https为`127.0.0.1:38457` * [具体配置详情](https://github.com/dotnetcore/FastGithub/blob/master/MacOSXConfig.md)