mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-29 00:26:09 +03:00
fix some issue
This commit is contained in:
parent
970843f561
commit
b71d1f2bc2
@ -8,6 +8,11 @@ namespace ProxySuper.Core.Models.Projects
|
|||||||
{
|
{
|
||||||
public class TrojanGoSettings : IProjectSettings
|
public class TrojanGoSettings : IProjectSettings
|
||||||
{
|
{
|
||||||
|
public TrojanGoSettings()
|
||||||
|
{
|
||||||
|
Port = 443;
|
||||||
|
}
|
||||||
|
|
||||||
public List<int> FreePorts
|
public List<int> FreePorts
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -8,6 +8,34 @@ namespace ProxySuper.Core.Models.Projects
|
|||||||
{
|
{
|
||||||
public partial class XraySettings : IProjectSettings
|
public partial class XraySettings : IProjectSettings
|
||||||
{
|
{
|
||||||
|
public XraySettings()
|
||||||
|
{
|
||||||
|
var guid = Guid.NewGuid().ToString();
|
||||||
|
Port = 443;
|
||||||
|
VLESS_KCP_Port = 2001;
|
||||||
|
VLESS_gRPC_Port = 2002;
|
||||||
|
VMESS_KCP_Port = 3001;
|
||||||
|
ShadowSocksPort = 4001;
|
||||||
|
|
||||||
|
UUID = guid;
|
||||||
|
Types = new List<XrayType>();
|
||||||
|
|
||||||
|
VLESS_WS_Path = "/vlessws";
|
||||||
|
VLESS_KCP_Type = "none";
|
||||||
|
VLESS_KCP_Seed = guid;
|
||||||
|
VLESS_gRPC_ServiceName = "xray_gRPC";
|
||||||
|
|
||||||
|
VMESS_WS_Path = "/vmessws";
|
||||||
|
VMESS_TCP_Path = "/vmesstcp";
|
||||||
|
VMESS_KCP_Seed = guid;
|
||||||
|
VMESS_KCP_Type = "none";
|
||||||
|
|
||||||
|
TrojanPassword = guid;
|
||||||
|
|
||||||
|
ShadowSocksPassword = guid;
|
||||||
|
ShadowSocksMethod = "aes-128-gcm";
|
||||||
|
}
|
||||||
|
|
||||||
public List<int> FreePorts
|
public List<int> FreePorts
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -16,13 +16,24 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ProxySuper.Core.Models
|
namespace ProxySuper.Core.Models
|
||||||
{
|
{
|
||||||
|
[JsonObject]
|
||||||
public class Record : MvxViewModel
|
public class Record : MvxViewModel
|
||||||
{
|
{
|
||||||
|
private Host _host;
|
||||||
|
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
[JsonProperty("host")]
|
[JsonProperty("host")]
|
||||||
public Host Host { get; set; }
|
public Host Host
|
||||||
|
{
|
||||||
|
get { return _host; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_host = value;
|
||||||
|
RaisePropertyChanged("Host");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[JsonProperty("settings")]
|
[JsonProperty("settings")]
|
||||||
public XraySettings XraySettings { get; set; }
|
public XraySettings XraySettings { get; set; }
|
||||||
@ -41,76 +52,6 @@ namespace ProxySuper.Core.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public IMvxNavigationService _navigationService;
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public IMvxNavigationService NavigationService
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_navigationService == null)
|
|
||||||
{
|
|
||||||
_navigationService = Mvx.IoCProvider.Resolve<IMvxNavigationService>();
|
|
||||||
}
|
|
||||||
return _navigationService;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public IMvxCommand NavToInstallerCommand => new MvxAsyncCommand(NavigateToInstaller);
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public IMvxCommand NavToEditorCommand => new MvxAsyncCommand(NavigateToEditor);
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public IMvxCommand NavToConfigCommand => new MvxAsyncCommand(NavigateToConfig);
|
|
||||||
|
|
||||||
public async Task NavigateToEditor()
|
|
||||||
{
|
|
||||||
if (Type == ProjectType.Xray)
|
|
||||||
{
|
|
||||||
var result = await NavigationService.Navigate<XrayEditorViewModel, Record, Record>(this);
|
|
||||||
if (result == null) return;
|
|
||||||
|
|
||||||
this.Host = result.Host;
|
|
||||||
this.XraySettings = result.XraySettings;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Type == ProjectType.TrojanGo)
|
|
||||||
{
|
|
||||||
var result = await NavigationService.Navigate<TrojanGoEditorViewModel, Record, Record>(this);
|
|
||||||
if (result == null) return;
|
|
||||||
|
|
||||||
this.Host = result.Host;
|
|
||||||
this.TrojanGoSettings = result.TrojanGoSettings;
|
|
||||||
}
|
|
||||||
await RaisePropertyChanged("Host");
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task NavigateToInstaller()
|
|
||||||
{
|
|
||||||
if (Type == ProjectType.Xray)
|
|
||||||
{
|
|
||||||
await NavigationService.Navigate<XrayInstallerViewModel, Record>(this);
|
|
||||||
}
|
|
||||||
if (Type == ProjectType.TrojanGo)
|
|
||||||
{
|
|
||||||
await NavigationService.Navigate<TrojanGoInstallerViewModel, Record>(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task NavigateToConfig()
|
|
||||||
{
|
|
||||||
if (Type == ProjectType.Xray)
|
|
||||||
{
|
|
||||||
await NavigationService.Navigate<XrayConfigViewModel, XraySettings>(this.XraySettings);
|
|
||||||
}
|
|
||||||
if (Type == ProjectType.TrojanGo)
|
|
||||||
{
|
|
||||||
await NavigationService.Navigate<TrojanGoConfigViewModel, TrojanGoSettings>(this.TrojanGoSettings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using MvvmCross.Navigation;
|
using MvvmCross.Navigation;
|
||||||
using MvvmCross.ViewModels;
|
using MvvmCross.ViewModels;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
using ProxySuper.Core.Models;
|
using ProxySuper.Core.Models;
|
||||||
using ProxySuper.Core.Models.Hosts;
|
using ProxySuper.Core.Models.Hosts;
|
||||||
using ProxySuper.Core.Models.Projects;
|
using ProxySuper.Core.Models.Projects;
|
||||||
@ -12,6 +13,7 @@ using System.Linq;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
namespace ProxySuper.Core.ViewModels
|
namespace ProxySuper.Core.ViewModels
|
||||||
{
|
{
|
||||||
@ -23,17 +25,9 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
{
|
{
|
||||||
_navigationService = navigationService;
|
_navigationService = navigationService;
|
||||||
ReadRecords();
|
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()
|
public void ReadRecords()
|
||||||
{
|
{
|
||||||
@ -58,7 +52,10 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
|
|
||||||
public void SaveToJson()
|
public void SaveToJson()
|
||||||
{
|
{
|
||||||
var json = JsonConvert.SerializeObject(this);
|
var json = JsonConvert.SerializeObject(Records, Formatting.Indented, new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||||
|
});
|
||||||
File.WriteAllText("Data/Record.json", json);
|
File.WriteAllText("Data/Record.json", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +65,14 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
|
|
||||||
public IMvxCommand AddTrojanGoCommand => new MvxAsyncCommand(AddTrojanGoRecord);
|
public IMvxCommand AddTrojanGoCommand => new MvxAsyncCommand(AddTrojanGoRecord);
|
||||||
|
|
||||||
|
public IMvxCommand RemoveCommand => new MvxAsyncCommand<string>(DeleteRecord);
|
||||||
|
|
||||||
|
public IMvxCommand EditCommand => new MvxAsyncCommand<string>(EditRecord);
|
||||||
|
|
||||||
|
public IMvxCommand ViewConfigCommand => new MvxAsyncCommand<string>(ViewConfig);
|
||||||
|
|
||||||
|
public IMvxCommand InstallCommand => new MvxAsyncCommand<string>(GoToInstall);
|
||||||
|
|
||||||
public async Task AddXrayRecord()
|
public async Task AddXrayRecord()
|
||||||
{
|
{
|
||||||
Record record = new Record();
|
Record record = new Record();
|
||||||
@ -80,8 +85,6 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
|
|
||||||
Records.Add(result);
|
Records.Add(result);
|
||||||
SaveToJson();
|
SaveToJson();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddTrojanGoRecord()
|
public async Task AddTrojanGoRecord()
|
||||||
@ -95,6 +98,74 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
if (result == null) return;
|
if (result == null) return;
|
||||||
|
|
||||||
Records.Add(result);
|
Records.Add(result);
|
||||||
|
|
||||||
|
SaveToJson();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task EditRecord(string id)
|
||||||
|
{
|
||||||
|
var record = Records.FirstOrDefault(x => x.Id == id);
|
||||||
|
if (record == null) return;
|
||||||
|
|
||||||
|
Record result = null;
|
||||||
|
if (record.Type == ProjectType.Xray)
|
||||||
|
{
|
||||||
|
result = await _navigationService.Navigate<XrayEditorViewModel, Record, Record>(record);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = await _navigationService.Navigate<TrojanGoEditorViewModel, Record, Record>(record);
|
||||||
|
}
|
||||||
|
if (result == null) return;
|
||||||
|
|
||||||
|
record.Host = result.Host;
|
||||||
|
record.XraySettings = result.XraySettings;
|
||||||
|
SaveToJson();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteRecord(string id)
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show($"您确认删除主机吗?", "提示", MessageBoxButton.OKCancel);
|
||||||
|
if (result == MessageBoxResult.OK)
|
||||||
|
{
|
||||||
|
var record = Records.FirstOrDefault(x => x.Id == id);
|
||||||
|
if (record != null)
|
||||||
|
{
|
||||||
|
Records.Remove(record);
|
||||||
|
SaveToJson();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ViewConfig(string id)
|
||||||
|
{
|
||||||
|
var record = Records.FirstOrDefault(x => x.Id == id);
|
||||||
|
if (record == null) return;
|
||||||
|
|
||||||
|
if (record.Type == ProjectType.Xray)
|
||||||
|
{
|
||||||
|
await _navigationService.Navigate<XrayConfigViewModel, XraySettings>(record.XraySettings);
|
||||||
|
}
|
||||||
|
if (record.Type == ProjectType.TrojanGo)
|
||||||
|
{
|
||||||
|
await _navigationService.Navigate<TrojanGoConfigViewModel, TrojanGoSettings>(record.TrojanGoSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GoToInstall(string id)
|
||||||
|
{
|
||||||
|
var record = Records.FirstOrDefault(x => x.Id == id);
|
||||||
|
if (record == null) return;
|
||||||
|
|
||||||
|
if (record.Type == ProjectType.Xray)
|
||||||
|
{
|
||||||
|
await _navigationService.Navigate<XrayInstallerViewModel, Record>(record);
|
||||||
|
}
|
||||||
|
if (record.Type == ProjectType.TrojanGo)
|
||||||
|
{
|
||||||
|
await _navigationService.Navigate<TrojanGoInstallerViewModel, Record>(record);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,5 +43,7 @@ namespace ProxySuper.Core.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string CommandText { get; set; }
|
public string CommandText { get; set; }
|
||||||
|
|
||||||
|
public string OutputText { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<sys:String x:Key="MainMenuActionsExportSettings">导出配置</sys:String>
|
<sys:String x:Key="MainMenuActionsExportSettings">导出配置</sys:String>
|
||||||
<sys:String x:Key="MainMenuActionsExportSubscribe">导出配置</sys:String>
|
<sys:String x:Key="MainMenuActionsExportSubscribe">导出配置</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="MainMenuLanguage">语言</sys:String>
|
<sys:String x:Key="MainMenuLanguage">语言(Language)</sys:String>
|
||||||
<sys:String x:Key="MainMenuLanguageEn">English</sys:String>
|
<sys:String x:Key="MainMenuLanguageEn">English</sys:String>
|
||||||
<sys:String x:Key="MainMenuLanguageCn">中文</sys:String>
|
<sys:String x:Key="MainMenuLanguageCn">中文</sys:String>
|
||||||
<sys:String x:Key="MainMenuHelper">帮助</sys:String>
|
<sys:String x:Key="MainMenuHelper">帮助</sys:String>
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
<MenuItem Padding="0,5" Header="NaiveProxy"></MenuItem>
|
<MenuItem Padding="0,5" Header="NaiveProxy"></MenuItem>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
||||||
<MenuItem Header="{DynamicResource MainMenuActions}" Padding="10,3">
|
<!--<MenuItem Header="{DynamicResource MainMenuActions}" Padding="10,3">
|
||||||
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSettings}"></MenuItem>
|
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSettings}"></MenuItem>
|
||||||
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSubscribe}"></MenuItem>
|
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSubscribe}"></MenuItem>
|
||||||
</MenuItem>
|
</MenuItem>-->
|
||||||
|
|
||||||
<MenuItem Header="{DynamicResource MainMenuLanguage}" Padding="10,3">
|
<MenuItem Header="{DynamicResource MainMenuLanguage}" Padding="10,3">
|
||||||
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuLanguageEn}" Click="SetEnglish"></MenuItem>
|
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuLanguageEn}" Click="SetEnglish"></MenuItem>
|
||||||
@ -53,37 +53,50 @@
|
|||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
<DataGridTextColumn Binding="{Binding Host.Tag}"
|
<DataGridTextColumn Binding="{Binding Host.Tag}"
|
||||||
Header="{DynamicResource MainDataGridColumnTag}"
|
Width="120">
|
||||||
Width="120" />
|
<DataGridTextColumn.Header>
|
||||||
|
<TextBlock Text="{DynamicResource MainDataGridColumnTag}" />
|
||||||
|
</DataGridTextColumn.Header>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
<DataGridTextColumn Binding="{Binding Host.Address}"
|
<DataGridTextColumn Binding="{Binding Host.Address}"
|
||||||
Header="{DynamicResource MainDataGridColumnAddress}"
|
Width="200">
|
||||||
Width="200" />
|
<DataGridTextColumn.Header>
|
||||||
|
<TextBlock Text="{DynamicResource MainDataGridColumnAddress}" />
|
||||||
|
</DataGridTextColumn.Header>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
<DataGridTextColumn Binding="{Binding Type}"
|
<DataGridTextColumn Binding="{Binding Type}"
|
||||||
Header="{DynamicResource MainDataGridColumnType}"
|
Width="200">
|
||||||
Width="200" />
|
<DataGridTextColumn.Header>
|
||||||
|
<TextBlock Text="{DynamicResource MainDataGridColumnType}" />
|
||||||
|
</DataGridTextColumn.Header>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
<DataGridTemplateColumn Header="{DynamicResource MainDataGridColumnAction}" Width="400">
|
<DataGridTemplateColumn Header="{DynamicResource MainDataGridColumnAction}" Width="400">
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<ItemContainerTemplate>
|
<ItemContainerTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Button Command="{Binding NavToInstallerCommand}"
|
<Button Command="{Binding DataContext.InstallCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
|
CommandParameter="{Binding Id}"
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Padding="12,3"
|
Padding="12,3"
|
||||||
Content="{DynamicResource MainDataGridColumnActionInstall}" />
|
Content="{DynamicResource MainDataGridColumnActionInstall}" />
|
||||||
|
|
||||||
<Button Command="{Binding NavToEditorCommand}"
|
<Button Command="{Binding DataContext.EditCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
|
CommandParameter="{Binding Id}"
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Padding="12,3"
|
Padding="12,3"
|
||||||
Content="{DynamicResource MainDataGridColumnActionEdit}" />
|
Content="{DynamicResource MainDataGridColumnActionEdit}" />
|
||||||
|
|
||||||
<Button Command="{Binding NavToConfigCommand}"
|
<Button Command="{Binding DataContext.ViewConfigCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
|
CommandParameter="{Binding Id}"
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Padding="12,3"
|
Padding="12,3"
|
||||||
Content="{DynamicResource MainDataGridColumnActionViewConfig}" />
|
Content="{DynamicResource MainDataGridColumnActionViewConfig}" />
|
||||||
|
|
||||||
<Button Command="{Binding NavToEditorCommand}"
|
<Button Command="{Binding DataContext.RemoveCommand,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
|
||||||
|
CommandParameter="{Binding Id}"
|
||||||
Margin="5,0"
|
Margin="5,0"
|
||||||
Padding="12,3"
|
Padding="12,3"
|
||||||
Content="{DynamicResource MainDataGridColumnActionDelete}" />
|
Content="{DynamicResource MainDataGridColumnActionDelete}" />
|
||||||
|
@ -74,6 +74,7 @@ namespace ProxySuper.WPF.Views
|
|||||||
outShell += "\n";
|
outShell += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewModel.OutputText += outShell;
|
||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
OutputTextBox.AppendText(outShell);
|
OutputTextBox.AppendText(outShell);
|
||||||
|
Loading…
Reference in New Issue
Block a user