1.1.1 更新

This commit is contained in:
Space Time 2024-06-07 10:05:39 +08:00
parent e502c6df2e
commit b9c3de4e75
5 changed files with 17 additions and 9 deletions

View File

@ -9,7 +9,7 @@ internal partial class MainConst : MainMultilangConst
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])*)*)?$")]

View File

@ -16,15 +16,15 @@ internal partial class MainPres : ObservableObject
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];
}

View File

@ -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;

View File

@ -5,7 +5,6 @@ using System.Windows.Interop;
namespace Sheas_Cealer.Utils;
// 定义 IconRemover
internal static partial class IconRemover
{
private const int GWL_EXSTYLE = -20;

View File

@ -130,16 +130,25 @@ public partial class MainWin : Window
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)