WIn_RustTools/RustTools/Views/HomePage.xaml.cs

142 lines
4.1 KiB
C#
Raw Normal View History

2024-07-19 07:36:44 +00:00
using System.Collections.ObjectModel;
2024-07-23 12:23:55 +00:00
using System.Diagnostics;
using Microsoft.UI;
using Microsoft.UI.Windowing;
2024-07-14 11:24:10 +00:00
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
2024-07-19 14:29:49 +00:00
using Newtonsoft.Json;
2024-07-23 12:23:55 +00:00
using RustTools.DataList;
2024-07-24 02:53:16 +00:00
using RustTools.muqing;
2024-07-23 12:23:55 +00:00
using RustTools.Services;
2024-07-14 11:24:10 +00:00
using RustTools.ViewModels;
2024-07-23 12:23:55 +00:00
using Windows.UI.WindowManagement;
2024-07-24 02:53:16 +00:00
using System.Threading;
2024-07-23 12:23:55 +00:00
namespace RustTools.Views;
2024-07-14 11:24:10 +00:00
public sealed partial class HomePage : Page
{
2024-07-23 12:23:55 +00:00
public HomePageViewModel ViewModel
{
2024-07-14 11:24:10 +00:00
get;
}
2024-07-19 07:36:44 +00:00
public ObservableCollection<Contact> conns = new();
2024-07-23 12:23:55 +00:00
public ObservableCollection<Contact> newlist = new();
2024-07-14 11:24:10 +00:00
2024-07-19 07:36:44 +00:00
public ObservableCollection<string> Pictures { get; } = new ObservableCollection<string>();
2024-07-14 11:24:10 +00:00
public HomePage()
{
2024-07-23 12:23:55 +00:00
ViewModel = App.GetService<HomePageViewModel>();
//<2F>ֲ<EFBFBD>ͼ
var lunbo = JsonConvert.DeserializeObject<HomeBanner>(ViewModel.lunbo);
if (lunbo != null)
{
foreach (var item in lunbo.data)
{
Pictures.Add(item.picture);
}
}
2024-07-24 02:53:16 +00:00
2024-07-19 07:36:44 +00:00
StartAsync();
2024-07-14 11:24:10 +00:00
InitializeComponent();
}
2024-07-24 02:53:16 +00:00
private async Task StartAsync()
2024-07-19 07:36:44 +00:00
{
var v = await wl.postAsync("/php/mod.php?action=random", new string[][]{
2024-07-24 02:53:16 +00:00
new string[] { "number", "6" }});
var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(v);
if (modListResponse != null)
2024-07-19 14:29:49 +00:00
{
2024-07-24 02:53:16 +00:00
conns.Clear();
foreach (var item in modListResponse.Data)
{
//https://rust.coldmint.top
if (item.Icon.Equals(""))
{
item.Icon = "/Assets/image/image.svg";
}
var contact = new Contact(item.Name, item.Description, item.UpdateTime + " " + item.CoinNumber + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
{
ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top")
};
conns.Add(contact);
}
2024-07-19 14:29:49 +00:00
}
var vv = await wl.postAsync("/php/mod.php?action=list", new string[][]{
2024-07-24 02:53:16 +00:00
new string[] { "sortMode", "latestTime" },
new string[] { "limit", "6" },
new string[] { "tag", "" }});
modListResponse = JsonConvert.DeserializeObject<ModListResponse>(vv);
if (modListResponse != null)
2024-07-19 14:29:49 +00:00
{
2024-07-24 02:53:16 +00:00
newlist.Clear();
foreach (var item in modListResponse.Data)
2024-07-19 14:29:49 +00:00
{
2024-07-24 02:53:16 +00:00
//https://rust.coldmint.top
if (item.Icon.Equals(""))
{
item.Icon = "/Assets/image/image.svg";
}
var contact = new Contact(item.Name, item.Description, item.UpdateTime + " " + item.CoinNumber + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")
{
ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top")
};
newlist.Add(contact);
2024-07-19 14:29:49 +00:00
}
}
2024-07-19 07:36:44 +00:00
}
public class Contact
{
2024-07-19 14:29:49 +00:00
public string Title
2024-07-19 07:36:44 +00:00
{
get; private set;
}
2024-07-19 14:29:49 +00:00
public string Message
2024-07-19 07:36:44 +00:00
{
get; private set;
}
2024-07-19 14:29:49 +00:00
public string Info
2024-07-19 07:36:44 +00:00
{
get; private set;
}
2024-07-19 14:29:49 +00:00
public string ImageUrl
{
get; set;
}
2024-07-19 07:36:44 +00:00
public Contact(string firstName, string lastName, string company)
{
2024-07-19 14:29:49 +00:00
Title = firstName;
Message = lastName;
Info = company;
2024-07-19 07:36:44 +00:00
}
}
2024-07-23 12:23:55 +00:00
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{
//var height = DisplayArea.Primary.WorkArea.Height;
//double a = height / 5;
//Debug.WriteLine(a);
//// <20><><EFBFBD><EFBFBD>FlipView<65>ĸ߶<C4B8>
//Banner.Height = a;
2024-07-19 07:36:44 +00:00
2024-07-23 12:23:55 +00:00
}
private void ListAClick(object sender, ItemClickEventArgs e)
{
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD>Windowʵ<77><CAB5>
Window newWindow = new Window
{
// <20><>NewPage<67><65><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>Window<6F><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Content = new ListViewPage(),
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Window<6F><77>һЩ<D2BB><D0A9><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>С
Title = "New Page",
};
// <20><>ʾ<EFBFBD><CABE>Window
newWindow.Show();
}
2024-07-14 11:24:10 +00:00
}