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

Storage optimization #7

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -64,7 +64,7 @@
public static object BackgroundColor;
public static ContextMenu BackgroundMenu;
public static List<ProxyCard> Cards = new();
public ProxyList()

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

Non-nullable property 'Proxies' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
InitializeComponent();
InitializeProxiesAsync();
Expand All @@ -87,7 +87,7 @@
using (var client = new HttpClient()) {
client.BaseAddress = new Uri(MainWindow.Avatar);
var Avatar = await client.GetAsync(client.BaseAddress).Await().Content.ReadAsStreamAsync();
var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Avatar.png");
var path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "./UserConfig/Avatar.png");

if (File.Exists(path))
{
Expand Down Expand Up @@ -129,7 +129,7 @@
}

}
catch (Exception ex)

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

The variable 'ex' is declared but never used

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

The variable 'ex' is declared but never used

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

The variable 'ex' is declared but never used
{
Logger.MsgBox("无法获取您的头像, 请稍后重试", "LocyanFrp", 0, 48, 1);
}
Expand Down Expand Up @@ -176,7 +176,7 @@
// 结果转换为字符串
string jsonString = await response.Content.ReadAsStringAsync();
// 结果序列化
responseObject = JsonConvert.DeserializeObject<GetProxiesResponseObject>(jsonString);

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

Converting null literal or possible null value to non-nullable type.
}
catch (Exception ex)
{
Expand Down Expand Up @@ -686,16 +686,16 @@
public class GetProxiesResponseObject
{
public int Status { get; set; }
public string Message { get; set; }

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

Non-nullable property 'Message' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public int Count { get; set; }
public List<Proxy> Proxies { get; set; }

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

[JsonProperty("proxy_name")]
public string ProxyName { get; set; }

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

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

[JsonProperty("proxy_type")]
public string ProxyType { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions LoCyanFrpDesktop/Dashboard/Settings.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LoCyanFrpDesktop.Utils;
using LoCyanFrpDesktop.Utils;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -56,9 +56,9 @@
{
return;
}
Access.DashBoard.Close();

Check warning on line 59 in LoCyanFrpDesktop/Dashboard/Settings.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

Dereference of a possibly null reference.

Check warning on line 59 in LoCyanFrpDesktop/Dashboard/Settings.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

Dereference of a possibly null reference.
if (File.Exists(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "session.token"))) {
File.Delete(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "session.token"));
if (File.Exists(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "./UserConfig/Information.json"))) {
File.Delete(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "./UserConfig/Information.json"));

}

Expand All @@ -66,7 +66,7 @@
Properties.Settings.Default.LoginToken = null;
Properties.Settings.Default.password = null;
MainWindow.islogin = false;
Access.MainWindow.Width = double.NaN;

Check warning on line 69 in LoCyanFrpDesktop/Dashboard/Settings.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

Dereference of a possibly null reference.

Check warning on line 69 in LoCyanFrpDesktop/Dashboard/Settings.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

Dereference of a possibly null reference.
Access.MainWindow.Show();
}
}
Expand Down
26 changes: 16 additions & 10 deletions LoCyanFrpDesktop/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -31,6 +31,7 @@
using HandyControl.Tools.Extension;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
using HandyControl.Controls;
using static System.Windows.Forms.AxHost;

namespace LoCyanFrpDesktop
{
Expand Down Expand Up @@ -66,7 +67,7 @@
this.Icon = new BitmapImage(iconUri);
if (Global.LoginedByConsole && Properties.Settings.Default.username != null && Properties.Settings.Default.password != null)
{
Login(Properties.Settings.Default.username, Properties.Settings.Default.password);

Check warning on line 70 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
}
Tips.Text = Global.Tips[Random.Shared.Next(0, Global.Tips.Count - 1)];
CheckNetworkAvailability();
Expand Down Expand Up @@ -144,20 +145,18 @@

private async Task<bool> CheckLogined()
{
string path = ".//session.token";
string path = "./UserConfig/Information.json";
if (!File.Exists(path))
{
return false;
}
else
{
string[] token_split;
try
{
char[] delimiters = { '|' };
token_split = File.ReadAllText(path).Split(delimiters);
username_auto = token_split[0];
token_auto = token_split[1];
var PathObject = JsonConvert.DeserializeObject<PathObject>(File.ReadAllText(path));
username_auto = PathObject.Username;
token_auto = PathObject.Token;
}
catch
{
Expand Down Expand Up @@ -235,8 +234,9 @@
Properties.Settings.Default.LoginToken = responseObject.Token;
Properties.Settings.Default.username = responseObject.UserData.Username;
Properties.Settings.Default.FrpToken = responseObject.UserData.FrpToken;
string path = ".//session.token";
string text = $"{responseObject.UserData.Username}|{responseObject.Token}";
string path = "./UserConfig/Information.json";
string text = $"{{\n \"Username\": \"{responseObject.UserData.Username}\",\n \"Token\": \"{responseObject.Token}\"\n}}";
Directory.CreateDirectory("./UserConfig");
File.WriteAllText(path, text);
islogin = true;
DashBoard = new DashBoard();
Expand Down Expand Up @@ -395,13 +395,13 @@
public int Status { get; set; }

[JsonProperty("username")]
public string Username { get; set; }

Check warning on line 398 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 398 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 398 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

[JsonProperty("email")]
public string Email { get; set; }

Check warning on line 401 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 401 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 401 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

[JsonProperty("token")]
public string Token { get; set; }

Check warning on line 404 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 404 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 404 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

[JsonProperty("traffic")]
public long Traffic { get; set; }
Expand All @@ -416,15 +416,15 @@
public int ProxiesNum { get; set; }

[JsonProperty("avatar")]
public string Avatar { get; set; }

Check warning on line 419 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 419 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 419 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

public class ResponseObject
{
public int Status { get; set; }
public string Message { get; set; }

Check warning on line 425 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 425 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 426 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 427 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

public class UserData
Expand All @@ -438,4 +438,10 @@
public string? Avatar { get; set; }
}

}
public class PathObject
{
public string Username { get; set; }

Check warning on line 443 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

Check warning on line 444 in LoCyanFrpDesktop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / BuildForWindows

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

}
4 changes: 3 additions & 1 deletion LoCyanFrpDesktop/Utils/Download.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Downloader;
using Downloader;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -195,6 +195,8 @@ public void UnpackAndAutoSetup()
{
File.Move(Path.Combine(DownloadPath, "Temp", FolderName, "frpc.exe"), Path.Combine(DownloadPath, "frpc.exe"));
}
Directory.Delete(Path.Combine(DownloadPath, "Temp"), true);
File.Delete(Path.Combine(DownloadPath, "frpc.temp")); // WHY 不删文件??
string path = Path.Combine(DownloadPath, "frpc.exe");
try
{
Expand Down
Loading