35 lines
969 B
C#
35 lines
969 B
C#
using System.Collections.ObjectModel;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using Newtonsoft.Json;
|
|
using RustTools.muqing;
|
|
|
|
namespace RustTools.ViewModels;
|
|
|
|
public partial class RankingViewModel : ObservableRecipient
|
|
{
|
|
public ObservableCollection<ModListResponse.ModData>? RankingList { get; set; } = new();
|
|
public RankingViewModel()
|
|
{
|
|
Init();
|
|
}
|
|
private void Init()
|
|
{
|
|
ListTab("downloadNumber");
|
|
}
|
|
|
|
public async void ListTab(string tab)
|
|
{
|
|
RankingList?.Clear();
|
|
//List必须小于10才能重新加载
|
|
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");
|
|
RankingList?.Add(item);
|
|
}
|
|
}
|
|
|
|
|
|
}
|