2024-08-16 05:15:18 +00:00
|
|
|
|
using System.Net.Http.Json;
|
|
|
|
|
using System.Security.Principal;
|
2024-07-15 05:22:53 +00:00
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
2024-08-16 05:15:18 +00:00
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
|
|
|
|
using Microsoft.UI.Xaml.Media.Imaging;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using RustTools.DataList;
|
|
|
|
|
using RustTools.muqing;
|
|
|
|
|
using RustTools.Themes;
|
2024-07-15 05:22:53 +00:00
|
|
|
|
using RustTools.ViewModels;
|
|
|
|
|
|
|
|
|
|
// To learn more about WinUI, the WinUI project structure,
|
|
|
|
|
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
|
|
|
|
|
|
|
|
namespace RustTools.Views;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class UserPage : Page
|
|
|
|
|
{
|
2024-08-16 05:15:18 +00:00
|
|
|
|
public UserSpaceInfo.UserData userInfo { get; set; } = new();
|
2024-08-15 01:40:33 +00:00
|
|
|
|
public UserViewModel UserViewModel
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
2024-07-15 05:22:53 +00:00
|
|
|
|
public UserPage()
|
|
|
|
|
{
|
2024-08-15 01:40:33 +00:00
|
|
|
|
UserViewModel = App.GetService<UserViewModel>();
|
2024-07-15 05:22:53 +00:00
|
|
|
|
InitializeComponent();
|
2024-08-16 05:15:18 +00:00
|
|
|
|
Init();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private async void Init()
|
|
|
|
|
{
|
|
|
|
|
var iniHelper = new IniHelper();
|
|
|
|
|
iniHelper.Load(IniHelper.FILE.User);
|
|
|
|
|
var account = iniHelper.GetValue(IniHelper.CODE.User, IniHelper.KEY.account);
|
|
|
|
|
var token = iniHelper.GetValue(IniHelper.CODE.User, IniHelper.KEY.token);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var v = await ApiFox.user.loginPc(account, token);
|
|
|
|
|
var userSpaceInfo = JsonConvert.DeserializeObject<UserSpaceInfo>(v);
|
|
|
|
|
|
|
|
|
|
//δ<><CEB4>¼
|
|
|
|
|
if (userSpaceInfo.Code == 0)
|
|
|
|
|
{
|
|
|
|
|
nulllogin();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await login(account);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
nulllogin();
|
|
|
|
|
gj.sc(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void nulllogin()
|
|
|
|
|
{
|
|
|
|
|
gridview.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed;
|
|
|
|
|
var loginPage = new LoginPage();
|
|
|
|
|
loginPage.LoginSucceeded += LoginPage_LoginSucceeded;
|
|
|
|
|
view.Children.Add(loginPage);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void LoginPage_LoginSucceeded(object sender, string account)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// <20><>¼<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD> Grid <20><><EFBFBD>Ƴ<EFBFBD> LoginPage
|
|
|
|
|
view.Children.Remove((LoginPage)sender);
|
|
|
|
|
await login(account);
|
|
|
|
|
}
|
|
|
|
|
public string aaa { get; set; } = "aaa";
|
|
|
|
|
|
|
|
|
|
private async Task login(string account)
|
|
|
|
|
{
|
|
|
|
|
var v = await ApiFox.user.SpaceInfo(account);
|
|
|
|
|
var userSpaceInfo = JsonConvert.DeserializeObject<UserSpaceInfo>(v);
|
|
|
|
|
if (userSpaceInfo != null && userSpaceInfo.Code == 0)
|
|
|
|
|
{
|
|
|
|
|
var data = userSpaceInfo.Data;
|
|
|
|
|
if (data == null) { return; }
|
|
|
|
|
data.HeadIcon=data.HeadIcon == string.Empty ? "/Assets/tool.png" : data.HeadIcon.Replace("..", wl.api);
|
|
|
|
|
gj.sc(data.HeadIcon);
|
|
|
|
|
userInfo = data;
|
|
|
|
|
|
|
|
|
|
DataContext = this;
|
|
|
|
|
}
|
|
|
|
|
gridview.Visibility = Microsoft.UI.Xaml.Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MenuFlyoutItemLogout_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var iniHelper = new IniHelper(IniHelper.FILE.User);
|
|
|
|
|
iniHelper.Clean();
|
|
|
|
|
iniHelper.Save();
|
|
|
|
|
nulllogin();
|
2024-07-15 05:22:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|