From 923839db18e2af6ccdf1224c065483bd6db512d7 Mon Sep 17 00:00:00 2001
From: xljiulang <366193849@qq.com>
Date: Sat, 24 Jul 2021 23:54:57 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8F=E8=A7=88=E5=99=A8?=
=?UTF-8?q?=E6=98=BE=E7=A4=BAreadme.html?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
FastGithub.Browser/BrowserHostedService.cs | 25 +++++++++++++++++++
.../BrowserServiceCollectionExtensions.cs | 21 ++++++++++++++++
FastGithub.Browser/FastGithub.Browser.csproj | 10 ++++++++
FastGithub.Upgrade/UpgradeHostedService.cs | 11 ++++++++
FastGithub/Program.cs | 2 +-
FastGithub/README.MD | 4 +--
FastGithub/README.html | 4 +--
7 files changed, 72 insertions(+), 5 deletions(-)
create mode 100644 FastGithub.Browser/BrowserHostedService.cs
create mode 100644 FastGithub.Browser/BrowserServiceCollectionExtensions.cs
create mode 100644 FastGithub.Browser/FastGithub.Browser.csproj
diff --git a/FastGithub.Browser/BrowserHostedService.cs b/FastGithub.Browser/BrowserHostedService.cs
new file mode 100644
index 0000000..1639e0b
--- /dev/null
+++ b/FastGithub.Browser/BrowserHostedService.cs
@@ -0,0 +1,25 @@
+using Microsoft.Extensions.Hosting;
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace FastGithub.Browser
+{
+ ///
+ /// 启动浏览器加载readme
+ ///
+ sealed class BrowserHostedService : IHostedService
+ {
+ public Task StartAsync(CancellationToken cancellationToken)
+ {
+
+ return Task.CompletedTask;
+ }
+
+ public Task StopAsync(CancellationToken cancellationToken)
+ {
+ return Task.CompletedTask;
+ }
+ }
+}
diff --git a/FastGithub.Browser/BrowserServiceCollectionExtensions.cs b/FastGithub.Browser/BrowserServiceCollectionExtensions.cs
new file mode 100644
index 0000000..0cb1fb9
--- /dev/null
+++ b/FastGithub.Browser/BrowserServiceCollectionExtensions.cs
@@ -0,0 +1,21 @@
+using FastGithub.Browser;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace FastGithub
+{
+ ///
+ /// 浏览器服务注册扩展
+ ///
+ public static class BrowserServiceCollectionExtensions
+ {
+ ///
+ /// 注册浏览器服务注册
+ ///
+ ///
+ ///
+ public static IServiceCollection AddBrowser(this IServiceCollection services)
+ {
+ return services.AddHostedService();
+ }
+ }
+}
diff --git a/FastGithub.Browser/FastGithub.Browser.csproj b/FastGithub.Browser/FastGithub.Browser.csproj
new file mode 100644
index 0000000..02a814b
--- /dev/null
+++ b/FastGithub.Browser/FastGithub.Browser.csproj
@@ -0,0 +1,10 @@
+
+
+
+ net5.0
+
+
+
+
+
+
diff --git a/FastGithub.Upgrade/UpgradeHostedService.cs b/FastGithub.Upgrade/UpgradeHostedService.cs
index 35fa681..7c8588b 100644
--- a/FastGithub.Upgrade/UpgradeHostedService.cs
+++ b/FastGithub.Upgrade/UpgradeHostedService.cs
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
+using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
@@ -41,6 +42,16 @@ namespace FastGithub.Upgrade
{
this.logger.LogWarning($"升级失败:{ex.Message}");
}
+
+ if (OperatingSystem.IsWindows() && Process.GetCurrentProcess().SessionId > 0)
+ {
+ await Task.Delay(TimeSpan.FromSeconds(2d), stoppingToken);
+ Process.Start(new ProcessStartInfo
+ {
+ UseShellExecute = true,
+ FileName = "https://localhost"
+ });
+ }
}
}
}
diff --git a/FastGithub/Program.cs b/FastGithub/Program.cs
index 12ffe2a..61ac886 100644
--- a/FastGithub/Program.cs
+++ b/FastGithub/Program.cs
@@ -44,8 +44,8 @@ namespace FastGithub
services.AddDnsServer();
services.AddDomainResolve();
services.AddHttpClient();
- services.AddAppUpgrade();
services.AddReverseProxy();
+ services.AddAppUpgrade();
services.AddSingleton();
services.Configure(ctx.Configuration.GetSection(nameof(FastGithub)));
})
diff --git a/FastGithub/README.MD b/FastGithub/README.MD
index bb57d01..3d7b188 100644
--- a/FastGithub/README.MD
+++ b/FastGithub/README.MD
@@ -6,8 +6,8 @@ github加速神器
* 双击运行FastGithub.exe程序
* 程序自动设置网络适配器的主DNS为127.0.0.1
* 程序自动安装CA证书到`将所有的证书都放入下载存储\受信任的根证书颁发机构`
-* FastGithub.exe start // 安装并启动服务
-* FastGithub.exe stop // 卸载并删除服务
+* FastGithub.exe start // 作为windows服务安装并启动
+* FastGithub.exe stop // 作为windows服务卸载并删除
#### linux本机
* 执行./FastGithub运行程序
diff --git a/FastGithub/README.html b/FastGithub/README.html
index 3e738c9..8e75f7d 100644
--- a/FastGithub/README.html
+++ b/FastGithub/README.html
@@ -23,8 +23,8 @@
双击运行FastGithub.exe程序
程序自动设置网络适配器的主DNS为127.0.0.1
程序自动安装CA证书到将所有的证书都放入下载存储\受信任的根证书颁发机构
- FastGithub.exe start // 安装并启动服务
- FastGithub.exe stop // 卸载并删除服务
+ FastGithub.exe start // 作为windows服务安装并启动
+ FastGithub.exe stop // 作为windows服务卸载并删除
linux本机