Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
Ver 2.1.0-RC3: Fixed Tons of the bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiroiame-Kusu committed Jun 22, 2024
1 parent 202c0d7 commit 92dd03c
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 178 deletions.
22 changes: 4 additions & 18 deletions LoCyanFrpDesktop/DashBoard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using LoCyanFrpDesktop.Utils;
using Wpf.Ui.Common;
using Microsoft.VisualBasic;
using System.Threading;

namespace LoCyanFrpDesktop
{
Expand All @@ -47,26 +48,11 @@ public DashBoard()
Uri iconUri = new Uri("pack://application:,,,/LoCyanFrpDesktop;component/Resource/favicon.ico", UriKind.RelativeOrAbsolute);
this.Icon = new BitmapImage(iconUri);
Access.DashBoard = this;
Task.Run(() => {
string Status;
if (CheckForUpdate(out Status))
{
//Output.Text = "检测到更新,如果没有自动更新记得自己去更新哦~";
Update.Init();
}

});



}
public bool CheckForUpdate(out string reason)
{
Console.WriteLine("Checking Update...");
bool a = false;
string Reason;
Update.CheckVersion(out a, out Reason);
reason = Reason;
return a;
}

public bool CheckIfFrpcInstalled()
{
if (!File.Exists(FrpcPathConfig))
Expand Down
17 changes: 11 additions & 6 deletions LoCyanFrpDesktop/Dashboard/ProxyList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@
Padding="10,5"
CornerRadius="8"
>
<StackPanel >
<DockPanel Name="ListPanel">

</DockPanel>
</StackPanel>
<!--
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel >

<WrapPanel Name="ListPanel">

</WrapPanel>


</StackPanel>
</ScrollViewer>
<!--
<ListView SelectionChanged="Proxies_List_SelectionChanged" Name="proxies_list" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10" ContextMenuOpening="ListView_ContextMenuOpening" MouseDown="ListView_MouseDown" MouseDoubleClick="proxies_list_MouseDoubleClick">
<ListView.ContextMenu>
Expand Down
17 changes: 6 additions & 11 deletions LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ private async Task<ObservableCollection<string>> GetProxiesListAsync()
Console.WriteLine(i);
Dispatcher.Invoke(() =>
{
var a = new ProxyCard(responseObject.Proxies[i],i);

ListPanel.Children.Add(a);
ListPanel.Children.Add(new ProxyCard(responseObject.Proxies[i], i));
/*ListPanel.Children.Add(new Card()
{
//Background = new SolidColorBrush(Colors.White),
Expand Down Expand Up @@ -420,7 +418,8 @@ public ProxyCard(Proxy ProxyInfo, int CardIndex)
Cards.Add(this);
//DefaultStyleKeyProperty.OverrideMetadata(typeof(ProxyCard), new FrameworkPropertyMetadata(typeof(ProxyCard)));
//this.Style.BasedOn = (Style)Application.Current.Resources["Card"];
this.Name = ProxyInfo.ProxyName;
string Name = ProxyInfo.ProxyName;
//this.Name = Name;
//this.OverridesDefaultStyle = true;
//this.Style = ProxyList.card.Style;
//Theme.Apply(ThemeType.Light);
Expand All @@ -434,7 +433,7 @@ public ProxyCard(Proxy ProxyInfo, int CardIndex)
this.HorizontalAlignment = HorizontalAlignment.Left;
this.VerticalAlignment = VerticalAlignment.Stretch;
this.MinHeight = 50;
this.MinWidth = 100;
this.Width = 200;
this.BorderBrush = new SolidColorBrush();
StackPanel stackPanel = new StackPanel()
{
Expand Down Expand Up @@ -710,20 +709,16 @@ public class Proxy
public string RemotePort { get; set; }

Check warning on line 709 in LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

Non-nullable property 'RemotePort' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[JsonProperty("use_compression")]
public bool UseCompression { get; set; }
public int UseCompression { get; set; }

[JsonProperty("use_encryption")]
public bool UseEncryption { get; set; }
public int UseEncryption { get; set; }
[JsonProperty("domain")]
public string Domain { get; set; }

Check warning on line 717 in LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

Non-nullable property 'Domain' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public int Node { get; set; }

[JsonProperty("icp")]
public object Icp { get; set; } // icp 字段可能为 null,使用 object 类型表示

Check warning on line 721 in LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

Non-nullable property 'Icp' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public override string ToString()
{
return $"{this.ProxyName} {ProxyType} {LocalIp}:{LocalPort}-->{Domain}:{RemotePort}";
}
}


Expand Down
2 changes: 1 addition & 1 deletion LoCyanFrpDesktop/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class Global
public static bool LoginedByConsole = false;
public const string Version = "2.1.0";
public const string Branch = "RC";
public const int Revision = 2;
public const int Revision = 3;
public static readonly BuildInfo BuildInfo = new();
public const string Developer = "Shiroiame-Kusu & Daiyangcheng";
public const string Copyright = "Copyright © 2021 - 2024 杭州樱芸网络科技有限公司 All Rights Reserved";
Expand Down
13 changes: 9 additions & 4 deletions LoCyanFrpDesktop/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public MainWindow()
//initialBanner.Show();
//initialBanner.Hide();
InitializeComponent();
if(Random.Shared.Next(0, 100) == Random.Shared.Next(0, 100))
{
throw new Exception("这是一个彩蛋,万分之一的机会");
}

Uri iconUri = new Uri("pack://application:,,,/LoCyanFrpDesktop;component/Resource/favicon.ico", UriKind.RelativeOrAbsolute);
this.Icon = new BitmapImage(iconUri);
if(Global.LoginedByConsole && Properties.Settings.Default.username != null && Properties.Settings.Default.password != null)
Expand All @@ -68,10 +73,10 @@ public MainWindow()

DataContext = this;
Access.MainWindow = this;


}
Update.Init();


}
private async void CheckNetworkAvailability()
{
bool b = true;
Expand Down Expand Up @@ -103,7 +108,7 @@ private async void CheckNetworkAvailability()
a();
}

}
}
}

public void OpenSnackbar(string title, string message, SymbolRegular icon)
Expand Down
2 changes: 1 addition & 1 deletion LoCyanFrpDesktop/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="BuildInfo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Utils\buildinfo.info;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>..\buildinfo.info;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Updater" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resource\net6.0\Updater.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
Expand Down
1 change: 0 additions & 1 deletion LoCyanFrpDesktop/Utils/Access.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ internal static class Access
public static MainWindow? MainWindow { get; set; }
public static DashBoard? DashBoard { get; set; }
public static Settings? Settings { get; set; }
public static InitialBanner? InitialBanner { get; set; }
}
}
27 changes: 11 additions & 16 deletions LoCyanFrpDesktop/Utils/Download.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,22 @@ public Download()
StartDownload();

}

public void InitDownloader()
{
var DownloadOption = new DownloadConfiguration()
{
BufferBlockSize = 10240,
// file parts to download, the default value is 1
ChunkCount = 8,
ChunkCount = 16,
// download speed limited to 2MB/s, default values is zero or unlimited
MaximumBytesPerSecond = 1024 * 1024 * 2,
// the maximum number of times to fail
MaxTryAgainOnFailover = 5,
MaxTryAgainOnFailover = 3,
// release memory buffer after each 50 MB
MaximumMemoryBufferBytes = 1024 * 1024 * 50,
// download parts of the file as parallel or not. The default value is false
ParallelDownload = true,
// number of parallel downloads. The default value is the same as the chunk count
ParallelCount = 4,
ParallelCount = 16,
// timeout (millisecond) per stream block reader, default values is 1000
Timeout = 3000,
// clear package chunks data when download completed with failure, default value is false
Expand Down Expand Up @@ -265,17 +263,18 @@ public static async Task<IDownloadService> DownloadFile(string url,string path)
}
private async void StartDownload()
{
var a = await RequestAPIandParse("https://api-gh.1l1.icu/repos/LoCyan-Team/LoCyanFrpPureApp/releases/latest");
var a = await RequestAPIandParse("https://api-gh.1l1.icu/repos/LoCyan-Team/LoCyanFrpPureApp/releases/latest",true);
if (!a)
{
await RequestAPIandParse("https://api.github.com/repos/LoCyan-Team/LoCyanFrpPureApp/releases/latest");
await RequestAPIandParse("https://api.github.com/repos/LoCyan-Team/LoCyanFrpPureApp/releases/latest", false);
}
}
private static async Task<bool> RequestAPIandParse(string url)
private static async Task<bool> RequestAPIandParse(string url,bool mirror)
{
try
{
var HttpClient = new HttpClient();
HttpClient.Timeout = TimeSpan.FromSeconds(5);
HttpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.188");
var Response = await HttpClient.GetAsync(url);
if (Response.IsSuccessStatusCode)
Expand All @@ -289,14 +288,10 @@ private static async Task<bool> RequestAPIandParse(string url)
Match match = Regex.Match(DownloadVersion, pattern);
var Version = match.Groups[1].Value;
string architecture = RuntimeInformation.OSArchitecture.ToString();
if (architecture == "X86")
{
TheFuckingLink = $"https://proxy-gh.1l1.icu/https://github.com/LoCyan-Team/LoCyanFrpPureApp/releases/download/{DownloadVersion}/frp_LoCyanFrp-{Version}_windows_386.zip";
}
else
{
TheFuckingLink = $"https://proxy-gh.1l1.icu/https://github.com/LoCyan-Team/LoCyanFrpPureApp/releases/download/{DownloadVersion}/frp_LoCyanFrp-{Version}_windows_amd64.zip";
}
var MirrorAddress = (mirror ? "https://proxy-gh.1l1.icu/" : "");
var _architecture = (architecture == "X86" ? "386" : "amd64");
TheFuckingLink = $"{MirrorAddress}https://github.com/LoCyan-Team/LoCyanFrpPureApp/releases/download/{DownloadVersion}/frp_LoCyanFrp-{Version}_windows_{_architecture}.zip";

FolderName = $"frp_LoCyanFrp-{Version}_windows_amd64";
Console.WriteLine(TheFuckingLink);

Expand Down
32 changes: 0 additions & 32 deletions LoCyanFrpDesktop/Utils/InitialBanner.xaml

This file was deleted.

69 changes: 0 additions & 69 deletions LoCyanFrpDesktop/Utils/InitialBanner.xaml.cs

This file was deleted.

8 changes: 5 additions & 3 deletions LoCyanFrpDesktop/Utils/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ public static void Output(LogType type, params object?[] objects)
{
line = line.TrimEnd(' ');
}
if (type == LogType.Debug || type == LogType.DetailDebug)
if (type == LogType.Info || type == LogType.Debug || type == LogType.DetailDebug)
{
Console.WriteLine(line);
return;
}

Access.Status.Dispatcher.Invoke(() => Access.Status.Append(LogPreProcess.Color(type, line)));
if (type == LogType.Error) {
Console.WriteLine("[Error] " + line); return;
}
Access.Status.Dispatcher.Invoke(() => Access.Status.Append(LogPreProcess.Color(type, line)));
LogPreProcess.Process.Cache.Add(new(type, line));
if (LogPreProcess.Process.Cache.Count > 200)
{
Expand Down
Loading

0 comments on commit 92dd03c

Please sign in to comment.