WIn_RustTools/RustTools/ViewModels/HomePageViewModel.cs

63 lines
2.3 KiB
C#
Raw Normal View History

using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
2024-07-19 14:29:49 +00:00
using Newtonsoft.Json;
2024-07-14 11:24:10 +00:00
namespace RustTools.ViewModels;
public partial class HomePageViewModel : ObservableRecipient
{
public ObservableCollection<ModListResponse.ModData> randomList = new();
public ObservableCollection<ModListResponse.ModData> latestTimeList = new();
2024-07-14 11:24:10 +00:00
public HomePageViewModel()
{
2024-07-19 14:29:49 +00:00
2024-07-14 11:24:10 +00:00
}
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()
{
2024-08-15 01:40:33 +00:00
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);
}
}
}
2024-07-23 12:23:55 +00:00
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}";
2024-07-14 11:24:10 +00:00
}