diff --git a/ProxySuper.Core/Models/Projects/XraySettings_SS.cs b/ProxySuper.Core/Models/Projects/XraySettings_SS.cs index b7d454a..debe70a 100644 --- a/ProxySuper.Core/Models/Projects/XraySettings_SS.cs +++ b/ProxySuper.Core/Models/Projects/XraySettings_SS.cs @@ -12,12 +12,12 @@ namespace ProxySuper.Core.Models.Projects /// /// ss password /// - public string ShadowsocksPassword { get; set; } + public string ShadowSocksPassword { get; set; } /// /// ss method /// - public string ShadowsocksMethod { get; set; } + public string ShadowSocksMethod { get; set; } /// /// ss port diff --git a/ProxySuper.Core/Models/Record.cs b/ProxySuper.Core/Models/Record.cs index 1809ca6..8aacd44 100644 --- a/ProxySuper.Core/Models/Record.cs +++ b/ProxySuper.Core/Models/Record.cs @@ -9,6 +9,7 @@ using ProxySuper.Core.Models.Projects; using ProxySuper.Core.ViewModels; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -56,7 +57,6 @@ namespace ProxySuper.Core.Models } } - [JsonIgnore] public IMvxCommand NavToInstallerCommand => new MvxAsyncCommand(NavigateToInstaller); @@ -76,7 +76,6 @@ namespace ProxySuper.Core.Models this.Host = result.Host; this.XraySettings = result.XraySettings; - await RaisePropertyChanged("Host"); } if (Type == ProjectType.TrojanGo) @@ -87,6 +86,7 @@ namespace ProxySuper.Core.Models this.Host = result.Host; this.TrojanGoSettings = result.TrojanGoSettings; } + await RaisePropertyChanged("Host"); } public async Task NavigateToInstaller() diff --git a/ProxySuper.Core/Services/ShareLink.cs b/ProxySuper.Core/Services/ShareLink.cs index 0fb6651..b82b48d 100644 --- a/ProxySuper.Core/Services/ShareLink.cs +++ b/ProxySuper.Core/Services/ShareLink.cs @@ -36,8 +36,8 @@ namespace ProxySuper.Core.Services private static string BuildShadowSocksShareLink(XraySettings settings) { - var _method = settings.ShadowsocksMethod; - var _password = settings.ShadowsocksPassword; + var _method = settings.ShadowSocksMethod; + var _password = settings.ShadowSocksPassword; var _server = settings.Domain; var _port = settings.ShadowSocksPort; diff --git a/ProxySuper.Core/Services/XrayConfigBuilder.cs b/ProxySuper.Core/Services/XrayConfigBuilder.cs index 39f98d5..09f19b2 100644 --- a/ProxySuper.Core/Services/XrayConfigBuilder.cs +++ b/ProxySuper.Core/Services/XrayConfigBuilder.cs @@ -201,8 +201,8 @@ namespace ProxySuper.Core.Services { var ssBound = GetBound("Shadowsocks-AEAD.json"); ssBound.port = parameters.ShadowSocksPort; - ssBound.settings.clients[0].password = parameters.ShadowsocksPassword; - ssBound.settings.clients[0].method = parameters.ShadowsocksMethod; + ssBound.settings.clients[0].password = parameters.ShadowSocksPassword; + ssBound.settings.clients[0].method = parameters.ShadowSocksMethod; xrayConfig.inbounds.Add(JToken.FromObject(ssBound)); } diff --git a/ProxySuper.Core/ViewModels/HomeViewModel.cs b/ProxySuper.Core/ViewModels/HomeViewModel.cs index 8cfb762..4f09de9 100644 --- a/ProxySuper.Core/ViewModels/HomeViewModel.cs +++ b/ProxySuper.Core/ViewModels/HomeViewModel.cs @@ -23,12 +23,27 @@ namespace ProxySuper.Core.ViewModels { _navigationService = navigationService; ReadRecords(); + _navigationService.AfterClose += _navigationService_AfterClose; + } + + private void _navigationService_AfterClose(object sender, MvvmCross.Navigation.EventArguments.IMvxNavigateEventArgs e) + { + if (e.ViewModel is XrayEditorViewModel || + e.ViewModel is TrojanGoEditorViewModel) + { + SaveToJson(); + } } public void ReadRecords() { - var json = File.ReadAllText("Data/Record.json"); - var records = JsonConvert.DeserializeObject>(json); + List records = new List(); + if (File.Exists("Data/Record.json")) + { + var json = File.ReadAllText("Data/Record.json"); + records = JsonConvert.DeserializeObject>(json); + } + this.Records = new MvxObservableCollection(); records.ForEach(item => @@ -41,9 +56,9 @@ namespace ProxySuper.Core.ViewModels }); } - public void SaveRecords() + public void SaveToJson() { - var json = JsonConvert.SerializeObject(Records); + var json = JsonConvert.SerializeObject(this); File.WriteAllText("Data/Record.json", json); } @@ -64,6 +79,9 @@ namespace ProxySuper.Core.ViewModels if (result == null) return; Records.Add(result); + SaveToJson(); + + } public async Task AddTrojanGoRecord() diff --git a/ProxySuper.Core/ViewModels/XrayConfigViewModel.cs b/ProxySuper.Core/ViewModels/XrayConfigViewModel.cs index 97b9f2a..3420b36 100644 --- a/ProxySuper.Core/ViewModels/XrayConfigViewModel.cs +++ b/ProxySuper.Core/ViewModels/XrayConfigViewModel.cs @@ -24,6 +24,76 @@ namespace ProxySuper.Core.ViewModels Settings = parameter; } + public bool Checked_VLESS_TCP_XTLS + { + get + { + return Settings.Types.Contains(XrayType.VLESS_TCP_XTLS); + } + } + public bool Checked_VLESS_TCP + { + get + { + return Settings.Types.Contains(XrayType.VLESS_TCP); + } + } + + public bool Checked_VLESS_WS + { + get + { + return Settings.Types.Contains(XrayType.VLESS_WS); + } + } + + public bool Checked_VLESS_KCP + { + get + { + return Settings.Types.Contains(XrayType.VLESS_KCP); + } + } + + public bool Checked_VMESS_TCP + { + get + { + return Settings.Types.Contains(XrayType.VMESS_TCP); + } + } + + public bool Checked_VMESS_WS + { + get + { + return Settings.Types.Contains(XrayType.VMESS_WS); + } + } + + public bool Checked_VMESS_KCP + { + get + { + return Settings.Types.Contains(XrayType.VMESS_KCP); + } + } + + public bool Checked_Trojan_TCP + { + get + { + return Settings.Types.Contains(XrayType.Trojan_TCP); + } + } + + public bool CheckedShadowSocks + { + get + { + return Settings.Types.Contains(XrayType.ShadowsocksAEAD); + } + } } } diff --git a/ProxySuper.Core/ViewModels/XrayEditorViewModel.cs b/ProxySuper.Core/ViewModels/XrayEditorViewModel.cs index bc8c7b9..3a2c4c5 100644 --- a/ProxySuper.Core/ViewModels/XrayEditorViewModel.cs +++ b/ProxySuper.Core/ViewModels/XrayEditorViewModel.cs @@ -174,18 +174,18 @@ namespace ProxySuper.Core.ViewModels } public string ShadowSocksPassword { - get => Settings.ShadowsocksPassword; - set => Settings.ShadowsocksPassword = value; + get => Settings.ShadowSocksPassword; + set => Settings.ShadowSocksPassword = value; } public string ShadowSocksMethod { - get => Settings.ShadowsocksMethod; + get => Settings.ShadowSocksMethod; set { var namespaceStr = typeof(ComboBoxItem).FullName + ":"; var trimValue = value.Replace(namespaceStr, ""); trimValue = trimValue.Trim(); - Settings.ShadowsocksMethod = trimValue; + Settings.ShadowSocksMethod = trimValue; RaisePropertyChanged("ShadowSocksMethod"); } } diff --git a/ProxySuper.WPF/Controls/HostControl.xaml b/ProxySuper.WPF/Controls/HostControl.xaml index b86fb33..b92cfe6 100644 --- a/ProxySuper.WPF/Controls/HostControl.xaml +++ b/ProxySuper.WPF/Controls/HostControl.xaml @@ -38,7 +38,7 @@ - + @@ -111,7 +111,7 @@ - +