142 lines
4.0 KiB
C#
142 lines
4.0 KiB
C#
using System.Collections.ObjectModel;
|
||
using System.Diagnostics;
|
||
using Microsoft.UI;
|
||
using Microsoft.UI.Windowing;
|
||
using Microsoft.UI.Xaml;
|
||
using Microsoft.UI.Xaml.Controls;
|
||
using Newtonsoft.Json;
|
||
using RustTools.DataList;
|
||
using RustTools.muqing;
|
||
using RustTools.Services;
|
||
using RustTools.ViewModels;
|
||
using Windows.UI.WindowManagement;
|
||
using System.Threading;
|
||
namespace RustTools.Views;
|
||
public sealed partial class HomePage : Page
|
||
{
|
||
public HomePageViewModel ViewModel
|
||
{
|
||
get;
|
||
}
|
||
public ObservableCollection<Contact> conns = new();
|
||
public ObservableCollection<Contact> newlist = new();
|
||
|
||
public ObservableCollection<string> Pictures { get; } = new ObservableCollection<string>();
|
||
public HomePage()
|
||
{
|
||
ViewModel = App.GetService<HomePageViewModel>();
|
||
//ÂÖ²¥Í¼
|
||
var lunbo = JsonConvert.DeserializeObject<HomeBanner>(ViewModel.lunbo);
|
||
if (lunbo != null)
|
||
{
|
||
foreach (var item in lunbo.data)
|
||
{
|
||
Pictures.Add(item.picture);
|
||
}
|
||
}
|
||
|
||
|
||
StartAsync();
|
||
InitializeComponent();
|
||
}
|
||
|
||
private async Task StartAsync()
|
||
{
|
||
var v = wl.post("/php/mod.php?action=random", new string[][]{
|
||
new string[] { "number", "6" }});
|
||
|
||
var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(v);
|
||
if (modListResponse != null)
|
||
{
|
||
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 + "´ÎÏÂÔØ")
|
||
{
|
||
ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top")
|
||
};
|
||
conns.Add(contact);
|
||
}
|
||
}
|
||
var vv = wl.post("/php/mod.php?action=list", new string[][]{
|
||
new string[] { "sortMode", "latestTime" },
|
||
new string[] { "limit", "6" },
|
||
new string[] { "tag", "" }});
|
||
modListResponse = JsonConvert.DeserializeObject<ModListResponse>(vv);
|
||
if (modListResponse != null)
|
||
{
|
||
newlist.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 + "´ÎÏÂÔØ")
|
||
{
|
||
ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top")
|
||
};
|
||
newlist.Add(contact);
|
||
}
|
||
}
|
||
}
|
||
|
||
public class Contact
|
||
{
|
||
public string Title
|
||
{
|
||
get; private set;
|
||
}
|
||
public string Message
|
||
{
|
||
get; private set;
|
||
}
|
||
public string Info
|
||
{
|
||
get; private set;
|
||
}
|
||
public string ImageUrl
|
||
{
|
||
get; set;
|
||
}
|
||
public Contact(string firstName, string lastName, string company)
|
||
{
|
||
Title = firstName;
|
||
Message = lastName;
|
||
Info = company;
|
||
}
|
||
}
|
||
|
||
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
||
{
|
||
//var height = DisplayArea.Primary.WorkArea.Height;
|
||
//double a = height / 5;
|
||
//Debug.WriteLine(a);
|
||
//// ÉèÖÃFlipViewµÄ¸ß¶È
|
||
//Banner.Height = a;
|
||
|
||
}
|
||
private void ListAClick(object sender, ItemClickEventArgs e)
|
||
{
|
||
// »ñÈ¡±»µã»÷µÄÏî
|
||
// ´´½¨Ò»¸öеÄWindowʵÀý
|
||
Window newWindow = new Window
|
||
{
|
||
// ½«NewPageÉèÖÃΪÐÂWindowµÄÄÚÈÝ
|
||
Content = new ListViewPage(),
|
||
|
||
// ÉèÖÃÐÂWindowµÄһЩÊôÐÔ£¬Èç±êÌâºÍ´óС
|
||
Title = "New Page",
|
||
};
|
||
|
||
// ÏÔʾÐÂWindow
|
||
newWindow.Show();
|
||
}
|
||
}
|