1.1.1 -> 1.1.2 第12次更新

This commit is contained in:
Space Time 2024-10-02 01:04:09 +08:00
parent 4c966e4b09
commit 7e85989fa8
2 changed files with 14 additions and 7 deletions

View File

@ -2,6 +2,7 @@
using System.IO; using System.IO;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Microsoft.Win32;
using Sheas_Cealer.Consts; using Sheas_Cealer.Consts;
using Sheas_Cealer.Props; using Sheas_Cealer.Props;
using File = System.IO.File; using File = System.IO.File;
@ -16,9 +17,12 @@ internal partial class MainPres : ObservableObject
int upstreamUrlIndex = Array.FindIndex(args, arg => arg.Equals("-u", StringComparison.OrdinalIgnoreCase)) + 1; int upstreamUrlIndex = Array.FindIndex(args, arg => arg.Equals("-u", StringComparison.OrdinalIgnoreCase)) + 1;
int extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", StringComparison.OrdinalIgnoreCase)) + 1; int extraArgsIndex = Array.FindIndex(args, arg => arg.Equals("-e", StringComparison.OrdinalIgnoreCase)) + 1;
BrowserPath = browserPathIndex == 0 || browserPathIndex == args.Length ? BrowserPath = browserPathIndex != 0 && browserPathIndex != args.Length ?args[browserPathIndex]:
!string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath : string.Empty : !string.IsNullOrWhiteSpace(Settings.Default.BrowserPath) ? Settings.Default.BrowserPath :
args[browserPathIndex]; (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe", string.Empty, null) ??
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe", string.Empty, null) ??
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\brave.exe", string.Empty, null) ??
string.Empty).ToString()!;
UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ? UpstreamUrl = upstreamUrlIndex == 0 || upstreamUrlIndex == args.Length ?
!string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl : !string.IsNullOrWhiteSpace(Settings.Default.UpstreamUrl) ? Settings.Default.UpstreamUrl : MainConst.DefaultUpstreamUrl :

View File

@ -177,11 +177,12 @@ public partial class MainWin : Window
private void HostWatcher_Changed(object sender, FileSystemEventArgs e) private void HostWatcher_Changed(object sender, FileSystemEventArgs e)
{ {
string hostName = e.Name!.TrimStart("Cealing-Host-".ToCharArray()).TrimEnd(".json".ToCharArray());
try try
{ {
string hostRulesFragments = string.Empty; string hostRulesFragments = string.Empty;
string hostResolverRulesFragments = string.Empty; string hostResolverRulesFragments = string.Empty;
string hostName = e.Name!.TrimStart("Cealing-Host-".ToCharArray()).TrimEnd(".json".ToCharArray());
int ruleIndex = 0; int ruleIndex = 0;
using FileStream hostStream = new(e.FullPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); using FileStream hostStream = new(e.FullPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
@ -202,7 +203,10 @@ public partial class MainWin : Window
} }
CealArgsFragments[hostName] = (hostRulesFragments, hostResolverRulesFragments); CealArgsFragments[hostName] = (hostRulesFragments, hostResolverRulesFragments);
}
catch { CealArgsFragments.Remove(hostName); }
finally
{
string hostRules = string.Empty; string hostRules = string.Empty;
string hostResolverRules = string.Empty; string hostResolverRules = string.Empty;
@ -212,9 +216,8 @@ public partial class MainWin : Window
hostResolverRules += CealArgsFragment.hostResolverRulesFragments; hostResolverRules += CealArgsFragment.hostResolverRulesFragments;
} }
CealArgs = @$"--host-rules=""{hostRules.TrimEnd(',')}"" --host-resolver-rules=""{hostResolverRules.TrimEnd(',')}"" --test-type --ignore-certificate-errors"; CealArgs = @$"/c @start .\""Uncealed-Browser.lnk"" --host-rules=""{hostRules.TrimEnd(',')}"" --host-resolver-rules=""{hostResolverRules.TrimEnd(',')}"" --test-type --ignore-certificate-errors";
} }
catch { CealArgs = string.Empty; }
} }
private void MainWin_KeyDown(object sender, KeyEventArgs e) private void MainWin_KeyDown(object sender, KeyEventArgs e)
{ {