Skip to content

Commit

Permalink
1.1.1 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceTimee committed Jun 7, 2024
1 parent e502c6d commit b9c3de4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Consts/MainConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal enum SettingsMode

internal static string DefaultUpstreamUrl => "https://gitlab.com/SpaceTimee/Cealing-Host/raw/main/Cealing-Host.json";

[GeneratedRegex(@"^(((ht|f)tps?):\/\/)?[a-zA-Z0-9](-*[a-zA-Z0-9])*(\.[a-zA-Z0-9](-*[a-zA-Z0-9])*)*(:\d{1,5})?(\/[a-zA-Z0-9.\-_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\%]*)*$")]
[GeneratedRegex(@"^(https?:\/\/)?[a-zA-Z0-9](-*[a-zA-Z0-9])*(\.[a-zA-Z0-9](-*[a-zA-Z0-9])*)*(:\d{1,5})?(\/[a-zA-Z0-9.\-_\~\!\$\&\'\(\)\*\+\,\;\=\:\@\%]*)*$")]
internal static partial Regex UpstreamUrlRegex();

[GeneratedRegex(@"^(--[a-z](-?[a-z])*( --[a-z](-?[a-z])*)*)?$")]
Expand Down
6 changes: 3 additions & 3 deletions Preses/MainPres.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ internal MainPres(string[] args)
int upstreamUrlIndex = Array.FindIndex(args, arg => arg.Equals("-u", StringComparison.OrdinalIgnoreCase)) + 1;
int extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", StringComparison.OrdinalIgnoreCase)) + 1;

BrowserPath = browserPathIndex == 0 ?
BrowserPath = browserPathIndex == 0 || browserPathIndex == args.Length ?
(!string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath : string.Empty) :
args[browserPathIndex];

UpstreamUrl = upstreamUrlIndex == 0 ?
UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
(!string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl) :
args[upstreamUrlIndex];

ExtraArgs = extraArgsIndex == 0 ?
ExtraArgs = extraArgsIndex == 0 || extraArgsIndex == args.Length ?
(!string.IsNullOrWhiteSpace(Settings.Default.ExtraArgs) ? Settings.Default.ExtraArgs : string.Empty) :
args[extraArgsIndex];
}
Expand Down
2 changes: 1 addition & 1 deletion Utils/CommandProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sheas_Cealer.Utils;

internal class CommandProc : Proc
{
internal bool ShutDownAppOnProcessExit;
private static bool ShutDownAppOnProcessExit;

internal CommandProc(bool shutDownAppOnProcessExit) : base("Cmd.exe") => ShutDownAppOnProcessExit = shutDownAppOnProcessExit;

Expand Down
1 change: 0 additions & 1 deletion Utils/IconRemover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace Sheas_Cealer.Utils;

// 定义 IconRemover
internal static partial class IconRemover
{
private const int GWL_EXSTYLE = -20;
Expand Down
15 changes: 12 additions & 3 deletions Wins/MainWin.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,25 @@ private void StartButtonHoldTimer_Tick(object? sender, EventArgs e)

private void EditHostButton_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo processStartInfo = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host.json")) { UseShellExecute = true };
string cealingHostPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host.json");

if (!File.Exists(cealingHostPath))
File.Create(cealingHostPath).Dispose();

ProcessStartInfo processStartInfo = new(cealingHostPath) { UseShellExecute = true };
Process.Start(processStartInfo);
}
private async void UpdateHostButton_Click(object sender, RoutedEventArgs e)
{
string upstreamHostUrl = MainPres!.UpstreamUrl;
string upstreamHostUrl = (MainPres!.UpstreamUrl.StartsWith("http://") || MainPres!.UpstreamUrl.StartsWith("https://") ? string.Empty : "https://") + MainPres!.UpstreamUrl;
string upstreamHostString = await Http.GetAsync<string>(upstreamHostUrl, MainClient);
string localHostPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host.json");
string localHostString;

using (StreamReader localHostStreamReader = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "Cealing-Host.json")))
if (!File.Exists(localHostPath))
File.Create(localHostPath).Dispose();

using (StreamReader localHostStreamReader = new(localHostPath))
localHostString = localHostStreamReader.ReadToEnd();

if (localHostString.Replace("\r", string.Empty) == upstreamHostString)
Expand Down

0 comments on commit b9c3de4

Please sign in to comment.