WIn_RustTools/RustTools/ViewModels/RankingViewModel.cs

35 lines
969 B
C#
Raw Permalink Normal View History

using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;
2024-08-26 09:41:33 +00:00
using RustTools.muqing;
2024-07-14 11:24:10 +00:00
namespace RustTools.ViewModels;
public partial class RankingViewModel : ObservableRecipient
{
2024-08-17 23:27:24 +00:00
public ObservableCollection<ModListResponse.ModData>? RankingList { get; set; } = new();
2024-07-14 11:24:10 +00:00
public RankingViewModel()
{
Init();
}
private void Init()
{
ListTab("downloadNumber");
}
public async void ListTab(string tab)
{
2024-08-26 09:41:33 +00:00
RankingList?.Clear();
//List必须小于10才能重新加载
2024-08-26 09:41:33 +00:00
var StringList = await ApiFox.mod.list(tab, "10", string.Empty);
var modData = JsonConvert.DeserializeObject<ModListResponse>(StringList);
foreach (var item in modData.Data)
{
item.Icon = item.Icon.Equals("") ? "/Assets/image/image.svg" : item.Icon.Replace("..", "https://rust.coldmint.top");
2024-08-26 09:41:33 +00:00
RankingList?.Add(item);
}
2024-07-14 11:24:10 +00:00
}
2024-07-14 11:24:10 +00:00
}