修复BUG,添加发布模组功能
This commit is contained in:
parent
b860f5fcc0
commit
636c673282
|
@ -1,4 +1,5 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using RestSharp;
|
||||||
using RustTools.muqing;
|
using RustTools.muqing;
|
||||||
|
|
||||||
namespace RustTools.ApiFox;
|
namespace RustTools.ApiFox;
|
||||||
|
@ -29,10 +30,16 @@ public class mod
|
||||||
|
|
||||||
public static async Task<string> list(string sortMode, string limit, string tag)
|
public static async Task<string> list(string sortMode, string limit, string tag)
|
||||||
{
|
{
|
||||||
var v = await wl.postAsync("/php/mod.php?action=list", new string[][]{
|
var strings = new string[][]{
|
||||||
new string[] { "sortMode", sortMode },
|
new string[] { "sortMode", sortMode },
|
||||||
new string[] { "limit", limit},
|
new string[] { "limit", limit},
|
||||||
new string[] { "tag",tag }});
|
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;
|
return v ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,4 +53,49 @@ public class mod
|
||||||
});
|
});
|
||||||
return v ?? string.Empty;
|
return v ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,14 +65,12 @@
|
||||||
Style="{StaticResource BodyStrongTextBlockStyle}"
|
Style="{StaticResource BodyStrongTextBlockStyle}"
|
||||||
Text="{Binding Description}"
|
Text="{Binding Description}"
|
||||||
TextTrimming="CharacterEllipsis" />
|
TextTrimming="CharacterEllipsis" />
|
||||||
<StackPanel Orientation="Horizontal">
|
<TextBlock Style="{StaticResource BodyTextBlockStyle}">
|
||||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding UpdateTime}" />
|
<Run Text="{Binding UpdateTime}" />
|
||||||
<TextBlock
|
<Run Text="{Binding DownloadNumber}" />
|
||||||
Margin="10,0,0,0"
|
<Run Text="次下载" />
|
||||||
Style="{StaticResource BodyTextBlockStyle}"
|
</TextBlock>
|
||||||
Text="{Binding CoinNumber}" />
|
|
||||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="次下载" />
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
14
RustTools/Themes/PostRwmod.xaml
Normal file
14
RustTools/Themes/PostRwmod.xaml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<UserControl
|
||||||
|
x:Class="RustTools.Themes.PostRwmod"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="using:RustTools.Themes"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
26
RustTools/Themes/PostRwmod.xaml.cs
Normal file
26
RustTools/Themes/PostRwmod.xaml.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||||
|
using Microsoft.UI.Xaml.Data;
|
||||||
|
using Microsoft.UI.Xaml.Input;
|
||||||
|
using Microsoft.UI.Xaml.Media;
|
||||||
|
using Microsoft.UI.Xaml.Navigation;
|
||||||
|
using Windows.Foundation;
|
||||||
|
using Windows.Foundation.Collections;
|
||||||
|
|
||||||
|
// To learn more about WinUI, the WinUI project structure,
|
||||||
|
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||||
|
|
||||||
|
namespace RustTools.Themes;
|
||||||
|
public sealed partial class PostRwmod : UserControl
|
||||||
|
{
|
||||||
|
public PostRwmod()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using RustTools.muqing;
|
||||||
|
|
||||||
namespace RustTools.ViewModels;
|
namespace RustTools.ViewModels;
|
||||||
|
|
||||||
|
@ -18,14 +19,14 @@ public partial class RankingViewModel : ObservableRecipient
|
||||||
|
|
||||||
public async void ListTab(string tab)
|
public async void ListTab(string tab)
|
||||||
{
|
{
|
||||||
RankingList.Clear();
|
RankingList?.Clear();
|
||||||
//List必须小于10才能重新加载
|
//List必须小于10才能重新加载
|
||||||
var StringList = await ApiFox.mod.list(tab, "10", "");
|
var StringList = await ApiFox.mod.list(tab, "10", string.Empty);
|
||||||
var modData = JsonConvert.DeserializeObject<ModListResponse>(StringList);
|
var modData = JsonConvert.DeserializeObject<ModListResponse>(StringList);
|
||||||
foreach (var item in modData.Data)
|
foreach (var item in modData.Data)
|
||||||
{
|
{
|
||||||
item.Icon = item.Icon.Equals("") ? "/Assets/image/image.svg" : item.Icon.Replace("..", "https://rust.coldmint.top");
|
item.Icon = item.Icon.Equals("") ? "/Assets/image/image.svg" : item.Icon.Replace("..", "https://rust.coldmint.top");
|
||||||
RankingList.Add(item);
|
RankingList?.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,8 @@
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="ToastTextBlock"
|
x:Name="ToastTextBlock"
|
||||||
Margin="0,16,0,0"
|
Margin="0,16,0,0"
|
||||||
IsTextSelectionEnabled="True" />
|
IsTextSelectionEnabled="True"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
</TeachingTip.Content>
|
</TeachingTip.Content>
|
||||||
|
|
||||||
</TeachingTip>
|
</TeachingTip>
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewmodels="using:RustTools.ViewModels"
|
xmlns:viewmodels="using:RustTools.ViewModels"
|
||||||
d:DataContext="{d:DesignInstance Type=viewmodels:RankingViewModel}"
|
d:DataContext="{d:DesignInstance Type=viewmodels:RankingViewModel}"
|
||||||
SizeChanged="Page_SizeChanged"
|
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|
|
@ -27,18 +27,13 @@ public sealed partial class RankingPage : Page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
||||||
{
|
|
||||||
//list.Height = ActualHeight - 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
|
private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var menu = (MenuFlyoutItem)sender;
|
var menu = (MenuFlyoutItem)sender;
|
||||||
if (menu != null && menu.Tag != null)
|
if (menu != null && menu.Tag != null)
|
||||||
{
|
{
|
||||||
var tag = (string)menu.Tag;
|
var tag = menu.Tag.ToString();
|
||||||
|
if (tag == null) { return; }
|
||||||
ViewModel.ListTab(tag);
|
ViewModel.ListTab(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user