66 lines
2.4 KiB
C#
66 lines
2.4 KiB
C#
using System.Collections.ObjectModel;
|
||
using CommunityToolkit.Mvvm.ComponentModel;
|
||
using Microsoft.UI.Xaml.Media.Imaging;
|
||
using Newtonsoft.Json;
|
||
using RustTools.muqing;
|
||
|
||
namespace RustTools.ViewModels;
|
||
|
||
public partial class HomePageViewModel : ObservableRecipient
|
||
{
|
||
public ObservableCollection<ModData> randomList = new();
|
||
public ObservableCollection<ModData> latestTimeList = new();
|
||
public HomePageViewModel()
|
||
{
|
||
|
||
}
|
||
|
||
public async void random()
|
||
{
|
||
var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(await ApiFox.mod.random());
|
||
if (modListResponse != null)
|
||
{
|
||
randomList.Clear();
|
||
foreach (var item in modListResponse.Data)
|
||
{
|
||
//https://rust.coldmint.top
|
||
if (item.Icon.Equals(""))
|
||
{
|
||
item.Icon = "/Assets/image/image.svg";
|
||
}
|
||
else
|
||
{
|
||
item.Icon = item.Icon.Replace("..", "https://rust.coldmint.top");
|
||
}
|
||
randomList.Add(item);
|
||
}
|
||
}
|
||
}
|
||
|
||
public async void Latest()
|
||
{
|
||
|
||
var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(await ApiFox.mod.list(ApiFox.mod.latestTime,"6",""));
|
||
if (modListResponse != null)
|
||
{
|
||
latestTimeList.Clear();
|
||
foreach (var item in modListResponse.Data)
|
||
{
|
||
//https://rust.coldmint.top
|
||
if (item.Icon.Equals(""))
|
||
{
|
||
item.Icon = "/Assets/image/image.svg";
|
||
}
|
||
else
|
||
{
|
||
item.Icon = item.Icon.Replace("..", "https://rust.coldmint.top");
|
||
}
|
||
latestTimeList.Add(item);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
public string lunbo = "{\r\n \"code\": 0,\r\n \"message\": \"获取成功,共1条记录\",\r\n \"data\": [\r\n {\r\n \"id\": \"67\",\r\n \"title\": \"博客\",\r\n \"owner\": \"coldmint\",\r\n \"picture\": \"https://rust.coldmint.top/resources/banner/1183ea9fe031b0787d07e7bdf4e28b3ef503ea0971.jpg\",\r\n \"link\": \"@link{https://coldmint.top/}\",\r\n \"createTime\": \"2023-05-13 10:38:01\",\r\n \"expirationTime\": \"2027-05-13 10:38:01\"\r\n }\r\n ]\r\n}";
|
||
}
|