mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-22 05:06:08 +03:00
save client info
This commit is contained in:
parent
b6e77b88b4
commit
77cf7737f7
@ -201,6 +201,9 @@
|
||||
<Compile Include="ViewModels\RecordViewModel.cs" />
|
||||
<Compile Include="ViewModels\Terminal.cs" />
|
||||
<Compile Include="ViewModels\XraySettingsViewModel.cs" />
|
||||
<Compile Include="Views\ClientInfoWindow.xaml.cs">
|
||||
<DependentUpon>ClientInfoWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -342,6 +345,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\ClientInfoWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -76,7 +76,9 @@ namespace ProxySU_Core.ViewModels
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
settings.Types.Add(XrayType.VLESS_TCP_TLS);
|
||||
if (!settings.Types.Contains(XrayType.VLESS_TCP_TLS))
|
||||
settings.Types.Add(XrayType.VLESS_TCP_TLS);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -97,7 +99,8 @@ namespace ProxySU_Core.ViewModels
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
settings.Types.Add(XrayType.VLESS_TCP_XTLS);
|
||||
if (!settings.Types.Contains(XrayType.VLESS_TCP_XTLS))
|
||||
settings.Types.Add(XrayType.VLESS_TCP_XTLS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -117,7 +120,8 @@ namespace ProxySU_Core.ViewModels
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
settings.Types.Add(XrayType.VLESS_WS_TLS);
|
||||
if (!settings.Types.Contains(XrayType.VLESS_WS_TLS))
|
||||
settings.Types.Add(XrayType.VLESS_WS_TLS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -138,7 +142,8 @@ namespace ProxySU_Core.ViewModels
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
settings.Types.Add(XrayType.VMESS_TCP_TLS);
|
||||
if (!settings.Types.Contains(XrayType.VMESS_TCP_TLS))
|
||||
settings.Types.Add(XrayType.VMESS_TCP_TLS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -159,7 +164,8 @@ namespace ProxySU_Core.ViewModels
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
settings.Types.Add(XrayType.VMESS_WS_TLS);
|
||||
if (!settings.Types.Contains(XrayType.VMESS_WS_TLS))
|
||||
settings.Types.Add(XrayType.VMESS_WS_TLS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -180,7 +186,8 @@ namespace ProxySU_Core.ViewModels
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
settings.Types.Add(XrayType.Trojan_TCP_TLS);
|
||||
if (!settings.Types.Contains(XrayType.Trojan_TCP_TLS))
|
||||
settings.Types.Add(XrayType.Trojan_TCP_TLS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
24
ProxySU_Core/Views/ClientInfoWindow.xaml
Normal file
24
ProxySU_Core/Views/ClientInfoWindow.xaml
Normal file
@ -0,0 +1,24 @@
|
||||
<metro:MetroWindow x:Class="ProxySU_Core.Views.ClientInfoWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:local="clr-namespace:ProxySU_Core.Views"
|
||||
mc:Ignorable="d"
|
||||
Title="ClientInfoWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
<TabControl
|
||||
Background="#fff"
|
||||
Style="{StaticResource MaterialDesignNavigatilRailTabControl}"
|
||||
Padding="10">
|
||||
<TabItem Width="200" Style="{StaticResource MaterialDesignNavigationRailTabItem}" Header="VLESS-TCP-XTLS"></TabItem>
|
||||
<TabItem Width="200" Style="{StaticResource MaterialDesignNavigationRailTabItem}" Header="VLESS-TCP-XTL"></TabItem>
|
||||
<TabItem Width="200" Style="{StaticResource MaterialDesignNavigationRailTabItem}" Header="VLESS-WebSocket-XTLS"></TabItem>
|
||||
<TabItem Width="200" Style="{StaticResource MaterialDesignNavigationRailTabItem}" Header="VMESS-TCP-XTL"></TabItem>
|
||||
<TabItem Width="200" Style="{StaticResource MaterialDesignNavigationRailTabItem}" Header="VLESS-WebSocket-XTL"></TabItem>
|
||||
<TabItem Width="200" Style="{StaticResource MaterialDesignNavigationRailTabItem}" Header="VLESS-TCP-Trojan"></TabItem>
|
||||
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</metro:MetroWindow>
|
32
ProxySU_Core/Views/ClientInfoWindow.xaml.cs
Normal file
32
ProxySU_Core/Views/ClientInfoWindow.xaml.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using ProxySU_Core.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ProxySU_Core.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// ClientInfoWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ClientInfoWindow
|
||||
{
|
||||
Record Record { get; set; }
|
||||
public ClientInfoWindow(Record record)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Record = record;
|
||||
|
||||
DataContext = this.Record;
|
||||
}
|
||||
}
|
||||
}
|
@ -96,6 +96,7 @@
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="{DynamicResource Connect}" FontSize="12" Height="24" Click="Connect" />
|
||||
<Button Content="{DynamicResource Edit}" FontSize="12" Height="24" Margin="10,0,0,0" Click="EditHost" />
|
||||
<Button Content="查看配置" FontSize="12" Height="24" Margin="10,0,0,0" Click="ShowClientInfo" />
|
||||
<Button Content="{DynamicResource Delete}" FontSize="12" Height="24" Margin="10,0,0,0" Click="DeleteHost" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using ProxySU_Core.Models;
|
||||
using ProxySU_Core.ViewModels;
|
||||
using ProxySU_Core.ViewModels.Developers;
|
||||
@ -56,6 +57,20 @@ namespace ProxySU_Core
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
private void SaveRecord()
|
||||
{
|
||||
var recordList = Records.Select(x => x.record);
|
||||
var json = JsonConvert.SerializeObject(recordList,
|
||||
Formatting.Indented,
|
||||
new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
});
|
||||
if (File.Exists("Data\\Record.json"))
|
||||
{
|
||||
File.WriteAllText("Data\\Record.json", json, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchGitHubSite(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@ -107,6 +122,7 @@ namespace ProxySU_Core
|
||||
if (result == true)
|
||||
{
|
||||
Records.Add(new RecordViewModel(newRecord));
|
||||
SaveRecord();
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,10 +135,20 @@ namespace ProxySU_Core
|
||||
if (result == true)
|
||||
{
|
||||
project.Notify();
|
||||
SaveRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowClientInfo(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataGrid.SelectedItem is RecordViewModel project)
|
||||
{
|
||||
var dialog = new ClientInfoWindow(project.record);
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void DeleteHost(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user