diff --git a/src/ST.Client.Desktop.Avalonia/ST.Client.Desktop.Avalonia.csproj b/src/ST.Client.Desktop.Avalonia/ST.Client.Desktop.Avalonia.csproj index 5c02969bc..4a7e7b64c 100644 --- a/src/ST.Client.Desktop.Avalonia/ST.Client.Desktop.Avalonia.csproj +++ b/src/ST.Client.Desktop.Avalonia/ST.Client.Desktop.Avalonia.csproj @@ -40,17 +40,17 @@ - - - - + + + + - + diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/GameListPage/HideAppWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/GameListPage/HideAppWindowViewModel.cs index 7b4a020f6..9d0eaabd4 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Windows/GameListPage/HideAppWindowViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/GameListPage/HideAppWindowViewModel.cs @@ -4,7 +4,6 @@ using Newtonsoft.Json.Linq; using ReactiveUI; using System.Application.Models; using System.Application.Models.Settings; -using System.Application.Services; using System.Application.UI.Resx; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -22,7 +21,7 @@ namespace System.Application.UI.ViewModels //_SteamHideApp = new ObservableCollection(); //_SteamHideApp.Subscribe(_ => this.RaisePropertyChanged(nameof(IsHideAppEmpty))); - SteamHideApp = ProxySettings.HideGameList.Value; + SteamHideApp = new ReadOnlyObservableCollection(ProxySettings.HideGameList.Value ?? new ObservableCollection()); this.WhenAnyValue(v => v.SteamHideApp) @@ -40,9 +39,12 @@ namespace System.Application.UI.ViewModels return null; }) .Subscribe(s => - { + { + if (ThreeStateEnable != s) + { _ThreeStateEnable = s; - this.RaisePropertyChanged(); + this.RaisePropertyChanged(nameof(ThreeStateEnable)); + } }) ); @@ -73,8 +75,8 @@ namespace System.Application.UI.ViewModels get => _SearchText; set => this.RaiseAndSetIfChanged(ref _SearchText, value); } - private ObservableCollection? _SteamHideApp; - public ObservableCollection? SteamHideApp + private ReadOnlyObservableCollection? _SteamHideApp; + public ReadOnlyObservableCollection? SteamHideApp { get => _SteamHideApp; set diff --git a/src/ST.Client/Models/ProxyDomain.cs b/src/ST.Client/Models/ProxyDomain.cs deleted file mode 100644 index b9d74d76e..000000000 --- a/src/ST.Client/Models/ProxyDomain.cs +++ /dev/null @@ -1,119 +0,0 @@ -using MessagePack; -using System.Collections.Generic; -using System.ComponentModel; - -namespace System.Application.Models -{ - [MessagePackObject(keyAsPropertyName: true)] - public class ProxyDomain - { - /// - /// 显示在UI上的名称 - /// - public string? Name { get; set; } - - /// - /// 代理域名合集 - /// - public IReadOnlyCollection? Domains { get; set; } - - /// - /// 端口 - /// - public int Port { get; set; } = 443; - - /// - /// 转发域名 - /// - public string? ToDomain { get; set; } - - /// - /// 转发域名IP - /// - public string? ProxyIPAddres { get; set; } - - /// - /// 伪装的ServerName - /// - public string? ServerName { get; set; } - - /// - /// 启用该域名代理 - /// - public bool IsEnable { get; set; } - - /// - /// 启用重定向 - /// - public bool IsRedirect { get; set; } - - public IReadOnlyCollection? Hosts { get; set; } - - public DomainTag DomainTag { get; set; } - } - - [TypeConverter(typeof(EnumDescriptionTypeConverter))] - public enum DomainTag : byte - { - [Description("steam社区")] - SteamCommunity = 0, - - [Description("steam商店")] - SteamStore = 1, - - [Description("steam部分图片修复")] - SteamImage = 2, - - [Description("steam好友服务")] - SteamChat = 3, - - [Description("Discord语音")] - Discord = 4, - - [Description("Twitch直播")] - Twitch = 5, - - [Description("Origin下载(Akamai)")] - OriginGameDownload = 6, - - [Description("GOG.COM")] - GOG = 7, - - [Description("Google(Recaptcha)")] - GoogleCode = 8, - - [Description("Github图片及资源修复")] - GithubContent = 9, - - [Description("Pixiv")] - Pixiv = 10, - - [Description("Discord更新下载")] - DiscordNet = 11, - - [Description("Uplay更新防劫持")] - UplayUpdate = 12, - - [Description("Twitch聊天")] - TwitchChat = 13, - - [Description("Github Gist")] - GithubGist = 14, - - [Description("Pixiv图片")] - PixivImage = 15, - - [Description("steam图片上传(聊天\\截图)")] - SteamImageUpload = 16, - - [Description("steam更新")] - SteamMeidia = 17, - } - -#if DEBUG - - [Obsolete("use ProxyDomain", true)] - public class ProxyDomainModel { } - -#endif -} \ No newline at end of file diff --git a/src/ST.Client/Models/ProxyScript.cs b/src/ST.Client/Models/ProxyScript.cs deleted file mode 100644 index 6b11e04cb..000000000 --- a/src/ST.Client/Models/ProxyScript.cs +++ /dev/null @@ -1,128 +0,0 @@ -using MessagePack; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; - -namespace System.Application.Models -{ - [MessagePackObject(keyAsPropertyName: true)] - public class ProxyScript - { - /// - /// 脚本文件路径 - /// - public string? FilePath { get; set; } - - /// - /// 脚本文件名称 - /// - public string? FileName { get; set; } - - /// - /// name - /// - public string? Name { get; set; } - - /// - /// namespace - /// - public string[]? NameSpace { get; set; } - - /// - /// Version - /// - public string? Version { get; set; } - - public string? HomepageURL { get; set; } - - public string? SupportURL { get; set; } - - public string? DownloadURL { get; set; } - - public string? UpdateURL { get; set; } - - /// - /// description - /// - public string? Description { get; set; } - - /// - /// author - /// - public string? Author { get; set; } - - /// - /// author - /// - public string[]? Match { get; set; } - - /// - /// include - /// - public string[]? Include { get; set; } - - /// - /// exclude - /// - public string[]? Exclude { get; set; } - - public string[]? Grant { get; set; } - - public string[]? Require { get; set; } - - public bool Enable { get; set; } - - public string? Content { get; set; } - - const string DescRegex = @"(?<={0})[\s\S]*?(?=\n)"; - - public static bool TryParse(string path, [NotNullWhen(true)] out ProxyScript? proxyScript) - { - var content = File.ReadAllText(path); - if (!string.IsNullOrEmpty(content)) - { - var userScript = content.Substring("==UserScript==", "==/UserScript=="); - if (!string.IsNullOrEmpty(userScript)) - { - var script = new ProxyScript - { - FilePath = path, - Content = RemoveComment(content.Replace("", "<\\/script>")), - //Content = content.Replace("", "<\\/script>").Replace(" ", "").Replace("\r", "").Replace("\n", "").Replace("\t", ""), - FileName = Path.GetFileName(path), - Name = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(Name)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true), - NameSpace = Regex.Matches(userScript, string.Format(DescRegex, $"@{nameof(NameSpace)}"), RegexOptions.IgnoreCase).GetValues(s => s.Success == true).ToArray(), - Version = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(Version)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true), - Description = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(Description)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true), - Author = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(Author)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true), - HomepageURL = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(HomepageURL)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true), - SupportURL = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(SupportURL)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true), - DownloadURL = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(DownloadURL)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true), - UpdateURL = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(UpdateURL)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true), - Exclude = Regex.Matches(userScript, string.Format(DescRegex, $"@{nameof(Exclude)}"), RegexOptions.IgnoreCase).GetValues(s => s.Success == true).ToArray(), - Grant = Regex.Matches(userScript, string.Format(DescRegex, $"@{nameof(Grant)}"), RegexOptions.IgnoreCase).GetValues(s => s.Success == true).ToArray(), - Require = Regex.Matches(userScript, string.Format(DescRegex, $"@{nameof(Require)}"), RegexOptions.IgnoreCase).GetValues(s => s.Success == true).ToArray() - }; - var matchs = Regex.Matches(userScript, string.Format(DescRegex, $"@{nameof(Match)}"), RegexOptions.IgnoreCase).GetValues(s => s.Success == true).ToArray(); - var Includes = Regex.Matches(userScript, string.Format(DescRegex, $"@{nameof(Include)}"), RegexOptions.IgnoreCase).GetValues(s => s.Success == true).ToArray(); - script.Match = matchs.Length == 0 ? Includes : matchs; - var enable = Regex.Match(userScript, string.Format(DescRegex, $"@{nameof(Enable)}"), RegexOptions.IgnoreCase).GetValue(s => s.Success == true); - - script.Enable = bool.TryParse(enable, out var e) && e; - proxyScript = script; - return true; - } - } - proxyScript = null; - return false; - } - - static string RemoveComment(string str) - { - var r = Regex.Replace(str, "^//.*", "", RegexOptions.Multiline); - - return Regex.Replace(r, @"^\s*\n", "", RegexOptions.Multiline); - } - } -} \ No newline at end of file