diff --git a/LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs b/LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs index 23730b5..8106768 100644 --- a/LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs +++ b/LoCyanFrpDesktop/Dashboard/ProxyList.xaml.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -87,7 +87,7 @@ private async void RefreshAvatar() 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)) { diff --git a/LoCyanFrpDesktop/Dashboard/Settings.xaml.cs b/LoCyanFrpDesktop/Dashboard/Settings.xaml.cs index e2d3c51..8d77354 100644 --- a/LoCyanFrpDesktop/Dashboard/Settings.xaml.cs +++ b/LoCyanFrpDesktop/Dashboard/Settings.xaml.cs @@ -1,4 +1,4 @@ -using LoCyanFrpDesktop.Utils; +using LoCyanFrpDesktop.Utils; using Microsoft.Win32; using System; using System.Collections.Generic; @@ -57,8 +57,8 @@ private void SignOut_Click(object sender, RoutedEventArgs e) return; } Access.DashBoard.Close(); - 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")); } diff --git a/LoCyanFrpDesktop/MainWindow.xaml.cs b/LoCyanFrpDesktop/MainWindow.xaml.cs index a5454e7..7e263d0 100644 --- a/LoCyanFrpDesktop/MainWindow.xaml.cs +++ b/LoCyanFrpDesktop/MainWindow.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -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 { @@ -144,20 +145,18 @@ private async void InitializeAutoLogin() private async Task 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(File.ReadAllText(path)); + username_auto = PathObject.Username; + token_auto = PathObject.Token; } catch { @@ -235,8 +234,9 @@ public async Task Login(string username, string password) 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(); @@ -438,4 +438,10 @@ public class UserData public string? Avatar { get; set; } } -} \ No newline at end of file + public class PathObject + { + public string Username { get; set; } + public string Token { get; set; } + } + +} diff --git a/LoCyanFrpDesktop/Utils/Download.xaml.cs b/LoCyanFrpDesktop/Utils/Download.xaml.cs index 9f10df7..80ed277 100644 --- a/LoCyanFrpDesktop/Utils/Download.xaml.cs +++ b/LoCyanFrpDesktop/Utils/Download.xaml.cs @@ -1,4 +1,4 @@ -using Downloader; +using Downloader; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -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 {