WIn_RustTools/RustTools/ApiFox/mod.cs

102 lines
3.3 KiB
C#
Raw Normal View History

2024-08-22 23:59:16 +00:00
using System.Diagnostics;
2024-08-26 09:41:33 +00:00
using RestSharp;
2024-08-22 23:59:16 +00:00
using RustTools.muqing;
namespace RustTools.ApiFox;
2024-08-22 23:59:16 +00:00
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
#pragma warning disable IDE1006 // 命名样式
public class mod
{
//最新时间 下载数量 投币数量 更新数量
//latestTime downloadNumbercoinNumber updateNumber
2024-08-22 23:59:16 +00:00
public const string latestTime = "latestTime";
public const string downloadNumber = "downloadNumber";
public const string coinNumber = "coinNumber";
public const string updateNumber = "updateNumber";
/// <summary>
/// 推荐接口
/// </summary>
/// <returns></returns>
public static async Task<string> random()
{
var v = await wl.postAsync("/php/mod.php?action=random", new string[][]{
new string[] { "number", "6" }});
return v ?? string.Empty;
}
public static async Task<string> list(string sortMode, string limit, string tag)
{
2024-08-26 09:41:33 +00:00
var strings = new string[][]{
new string[] { "sortMode", sortMode },
new string[] { "limit", limit},
2024-08-26 09:41:33 +00:00
new string[] { "tag",tag }};
//if (string.IsNullOrWhiteSpace(tag)) {
// strings = new string[][]{
// new string[] { "sortMode", sortMode },
// new string[] { "limit", limit} };
//}
var v = await wl.postAsync("/php/mod.php?action=list",strings) ;
return v ?? string.Empty;
}
public static async Task<string> getInfo(string account, string modId)
{
2024-08-15 01:40:33 +00:00
var v = await wl.postAsync("/php/mod.php?action=getInfo", new string[][]{
new string[] { "account", account },
new string[] { "modId", modId}
});
return v ?? string.Empty;
}
2024-08-26 09:41:33 +00:00
/// <summary>
/// 发布模组
/// </summary>
/// <returns></returns>
public static async Task<string> release(releaseData releaseData)
{
var client = new RestClient(wl.api);
var request = new RestRequest("/php/mod.php?action=release",Method.Post);
request.AddParameter("token", "");
request.AddParameter("appID", "");
request.AddParameter("modId", "");
request.AddParameter("modName", "");
request.AddParameter("describe", "");
request.AddParameter("tags", "");
request.AddParameter("unitNumber", "");
request.AddParameter("versionName", "");
request.AddParameter("minVersion", "");
request.AddFile("file", "");
request.AddFile("iconFile", "");
for (var i = 0; i < releaseData.screenshot.Count; i++)
{
request.AddFile($"screenshot_{i}", releaseData.screenshot[i]);
}
var response = client.Execute(request);
return response.Content??string.Empty;
}
public class releaseData
{
public string token = "";
public string appID = "";
public string modId = "";
public string modName = "";
public string describe = "";
public string tags = "";
public string unitNumber = "";
public string versionName = "";
public string minVersion = "";
public string file = "";
public string iconFile = "";
public List<string> screenshot = new();
}
}