Merge pull request 'master' (#1) from muqing/WIn_RustTools:master into master

Reviewed-on: Cold-Mint/WIn_RustTools#1
This commit is contained in:
Cold-Mint 2024-07-26 01:17:30 +00:00
commit e160d41f04
14 changed files with 502 additions and 211 deletions

50
RustTools/ApiFox/mod.cs Normal file
View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RustTools.muqing;
namespace RustTools.ApiFox;
class mod
{
//最新时间 下载数量 投币数量 更新数量
//latestTime downloadNumbercoinNumber updateNumber
public static string latestTime = "latestTime";
public static string downloadNumber = "downloadNumber";
public static string coinNumber = "coinNumber";
public static 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)
{
var v = await wl.postAsync("/php/mod.php?action=list", new string[][]{
new string[] { "sortMode", sortMode },
new string[] { "limit", limit},
new string[] { "tag",tag }});
return v ?? string.Empty;
}
public static async Task<string> getInfo(string account, string modId)
{
var v = await wl.postAsync("/php/mod.php?action=getInfo", new string[][]{
new string[] { "account", account },
new string[] { "modId", modId}
});
return v ?? string.Empty;
}
}

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
height="106px" width="106px"
viewBox="0 -960 960 960" fill="#e8eaed">
<path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z"/>
</svg>

After

Width:  |  Height:  |  Size: 344 B

View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1721905357214" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="26869" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M298.666667 896a32 32 0 0 1 32-32h362.666666a32 32 0 0 1 0 64h-362.666666A32 32 0 0 1 298.666667 896zM382.72 340.053333a32 32 0 0 1 45.226667 0L512 424.106667l84.053333-84.053334a32 32 0 1 1 45.226667 45.226667l-97.28 97.28v136.106667a32 32 0 0 1-64 0v-136.106667L382.72 385.28a32 32 0 0 1 0-45.226667z" fill="#777A80" p-id="26870"></path><path d="M661.333333 662.4l23.978667-19.2a277.333333 277.333333 0 1 0-346.624 0l23.978667 19.2V725.333333a21.333333 21.333333 0 0 0 21.333333 21.333334h256a21.333333 21.333333 0 0 0 21.333333-21.333334v-62.933333z m64 30.72V725.333333a85.333333 85.333333 0 0 1-85.333333 85.333334H384a85.333333 85.333333 0 0 1-85.333333-85.333334v-32.213333a341.333333 341.333333 0 1 1 426.666666 0z" fill="#777A80" p-id="26871"></path></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -5,52 +5,51 @@ using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace RustTools.DataList
namespace RustTools.DataList;
public class HomeBanner
{
class HomeBanner
public int code
{
public int code
get; set;
}
public string message
{
get; set;
}
public Data[] data
{
get; set;
}
public class Data
{
public string id
{
get; set;
}
public string message
public string title
{
get; set;
}
public Data[] data
public string owner
{
get; set;
}
public class Data
public string picture
{
public string id
{
get; set;
}
public string title
{
get; set;
}
public string owner
{
get; set;
}
public string picture
{
get; set;
}
public string link
{
get; set;
}
public DateTime createTime
{
get; set;
}
public DateTime expirationTime
{
get; set;
}
get; set;
}
public string link
{
get; set;
}
public DateTime createTime
{
get; set;
}
public DateTime expirationTime
{
get; set;
}
}
}

View File

@ -0,0 +1,127 @@
using System;
using Newtonsoft.Json;
public class ModInfo
{
[JsonProperty("code")]
public int Code
{
get; set;
}
[JsonProperty("message")]
public string Message
{
get; set;
}
[JsonProperty("data")]
public Data data
{
get; set;
}
public class Data
{
[JsonProperty("id")]
public string Id
{
get; set;
}
[JsonProperty("name")]
public string Name
{
get; set;
}
[JsonProperty("describe")]
public string Description
{
get; set;
}
[JsonProperty("icon")]
public string IconUrl
{
get; set;
}
[JsonProperty("tags")]
public string Tags
{
get; set;
}
[JsonProperty("screenshots")]
public string Screenshots
{
get; set;
}
[JsonProperty("developer")]
public string Developer
{
get; set;
}
[JsonProperty("link")]
public string Link
{
get; set;
}
[JsonProperty("downloadNumber")]
public string DownloadNumber
{
get; set;
}
[JsonProperty("versionNumber")]
public string VersionNumber
{
get; set;
}
[JsonProperty("versionName")]
public string VersionName
{
get; set;
}
[JsonProperty("updateTime")]
public DateTime UpdateTime
{
get; set;
}
[JsonProperty("creationTime")]
public DateTime CreationTime
{
get; set;
}
[JsonProperty("unitNumber")]
public string UnitNumber
{
get; set;
}
[JsonProperty("hidden")]
public string Hidden
{
get; set;
}
[JsonProperty("coinNumber")]
public string CoinNumber
{
get; set;
}
[JsonProperty("minVersion")]
public string MinVersion
{
get; set;
}
}
}

View File

@ -31,9 +31,10 @@
<Page Remove="Assets\新文件夹\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Assets\image\image_106.svg" />
<None Remove="Views\Concern.xaml" />
<None Remove="Views\HomePage.xaml" />
<None Remove="Views\ListViewPage.xaml" />
<None Remove="Views\ModulePage.xaml" />
<None Remove="Views\RankingPage.xaml" />
<None Remove="Views\UserPage.xaml" />
</ItemGroup>
@ -67,7 +68,7 @@
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<Page Update="Views\ListViewPage.xaml">
<Page Update="Views\ModulePage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\Concern.xaml">
@ -106,5 +107,6 @@
<ItemGroup>
<Content Remove="Assets\image\image_24dp_E8EAED_FILL0_wght400_GRAD0_opsz24 (1).svg" />
<Content Remove="Assets\创意工坊.svg" />
</ItemGroup>
</Project>

View File

@ -1,16 +1,66 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.UI.Xaml.Media.Imaging;
using Newtonsoft.Json;
using RustTools.muqing;
namespace RustTools.ViewModels;
public partial class HomePageViewModel : ObservableRecipient
{
public ObservableCollection<ModData> randomList = new();
public ObservableCollection<ModData> latestTimeList = new();
public HomePageViewModel()
{
}
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()
{
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);
}
}
}
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}";
public string str = "{\r\n \"code\": 0,\r\n \"message\": \"获取成功共6条记录\",\r\n \"data\": [\r\n {\r\n \"id\": \"csj_shi_ji\",\r\n \"name\": \"创世纪\",\r\n \"describe\": \"创世纪已经运行了3个月发布铁锈盒子禁止进行盗素材行为素材均已得到绘画者许可。\",\r\n \"icon\": \"../user/lanxing/mods/csj_shi_ji/icon.png\",\r\n \"developer\": \"lanxing\",\r\n \"downloadNumber\": null,\r\n \"updateTime\": \"2024-07-19 09:03:17\",\r\n \"coinNumber\": \"0\",\r\n \"unitNumber\": \"203\",\r\n \"versionNumber\": \"1\"\r\n },\r\n {\r\n \"id\": \"tie_xiu_za_jiao_ban\",\r\n \"name\": \"铁锈杂交版\",\r\n \"describe\": \"原版单位融合 by虚谷\",\r\n \"icon\": \"\",\r\n \"developer\": \"chrwow\",\r\n \"downloadNumber\": \"1\",\r\n \"updateTime\": \"2024-07-18 14:29:36\",\r\n \"coinNumber\": \"0\",\r\n \"unitNumber\": \"5\",\r\n \"versionNumber\": \"1\"\r\n },\r\n {\r\n \"id\": \"xi_wang_an_quan\",\r\n \"name\": \"希望安全\",\r\n \"describe\": \"实验性位移系统;\\n三抗\\n抗血量提取抗运输槽删除抗渗透回收\\n复杂的全局保险机制\\n计划重写一些铁锈的功能来方便完成自己离谱需求预计有\\n位移队伍\\n随便把之前mod没有完成的目标填坑。\\n至于BSJ倾向则是为了告诉自己活着至少还行尽管无法与火和挺立的树相比不要问曾经经历过什么。\",\r\n \"icon\": \"../user/Compulsory_registrat/mods/xi_wang_an_quan/icon.png\",\r\n \"developer\": \"Compulsory_registrat\",\r\n \"downloadNumber\": \"1\",\r\n \"updateTime\": \"2024-07-18 12:04:37\",\r\n \"coinNumber\": \"0\",\r\n \"unitNumber\": \"10\",\r\n \"versionNumber\": \"1\"\r\n },\r\n {\r\n \"id\": \"mod_xing\",\r\n \"name\": \"无尽星空-星海乐章(公测版0.1.3)\",\r\n \"describe\": \"\\\"星空浩瀚无比,征途永无止境.\\\"\\n-经历了十个版本内测,星海乐章公测版终于出炉啦!\\n-感谢『12rwmod』和其他小伙伴提出的各种改进建议\\n-模组背景音乐: Caught Adrift - Another Day, Strings For A Queen (Original Mix), Faster Than Light, The Remnant, Daylight. (排序不分先后)\\n-模组系列:『无尽星空』,单部:『星海乐章』\\n-作者是『幻梦星璃(星)』\\n-模组交流群『✨蓝星方舟中控部✨』(群号:757914038)\\n-建议用自定义地图里的太空玩哦.\\n-温馨提示:想玩这个模组需要用1.15的铁锈战争哦(没有的话,没关系,进群拿.)\\n-对了,人机可能会有一点点强哦,建议从低难度开始慢慢来.\\n@qqGroup{757914038}\",\r\n \"icon\": \"https://rust.coldmint.top/user/7854399/mods/mod_xing/icons/8222d5e5-b53f-5186-489d-a680b338ca5f.png\",\r\n \"developer\": \"7854399\",\r\n \"downloadNumber\": \"1226\",\r\n \"updateTime\": \"2024-07-17 19:14:02\",\r\n \"coinNumber\": \"59\",\r\n \"unitNumber\": \"228\",\r\n \"versionNumber\": \"69\"\r\n },\r\n {\r\n \"id\": \"shi_kong_jun_zhu\",\r\n \"name\": \"时空君主:魔法战争-人族1.7\",\r\n \"describe\": \"伟大永恒而无聊的时空君主,你加入了其他时空君主们的游戏,本次游戏中你们将召唤一个个来自魔法世界工业科技时代的士兵,为你们找点乐子!附注:建议标准4000开局。拒绝搬运反对外传禁止盗用侵权必究by.小小的工作室,可加群:411238064交流当前仅在QQ群411238064正式发布绝对免费如有其他途径发现不要购买就是对作者最大的支持\",\r\n \"icon\": \"\",\r\n \"developer\": \"18234474931\",\r\n \"downloadNumber\": \"1\",\r\n \"updateTime\": \"2024-07-16 08:06:14\",\r\n \"coinNumber\": \"0\",\r\n \"unitNumber\": \"21\",\r\n \"versionNumber\": \"1\"\r\n },\r\n {\r\n \"id\": \"yuanban_danwei_kuozhan\",\r\n \"name\": \"原版单位扩展(by:未开智物种)\",\r\n \"describe\": \"平衡小调整\",\r\n \"icon\": \"https://rust.coldmint.top/user/wls20081024/mods/yuanban_danwei_kuozhan/icon.png\",\r\n \"developer\": \"wls20081024\",\r\n \"downloadNumber\": \"24\",\r\n \"updateTime\": \"2024-07-13 15:53:21\",\r\n \"coinNumber\": \"2\",\r\n \"unitNumber\": \"26\",\r\n \"versionNumber\": \"5\"\r\n }\r\n ]\r\n}";
}

View File

@ -4,6 +4,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:data="using:RustTools.DataList"
xmlns:local="using:RustTools.Views"
xmlns:local1="using:Windows.ApplicationModel.Contacts"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -19,24 +20,33 @@
BorderThickness="0"
CornerRadius="9">
<Border.Background>
<ImageBrush ImageSource="{Binding ImageUrl}" Stretch="UniformToFill" />
<ImageBrush ImageSource="{Binding Icon}" Stretch="UniformToFill" />
</Border.Background>
</Border>
<StackPanel Margin="10,10,10,10" Orientation="Vertical">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Title}" />
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Name}" />
<TextBlock
Width="500"
MaxLines="2"
Style="{StaticResource BodyStrongTextBlockStyle}"
Text="{Binding Message}"
Text="{Binding Description}"
TextTrimming="CharacterEllipsis"
TextWrapping="Wrap" />
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Info}" />
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding UpdateTime}" />
<TextBlock
Margin="10,0,0,0"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding CoinNumber}" />
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="次下载" />
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</Page.Resources>
<ScrollView HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<StackPanel Orientation="Vertical">
<FlipView
@ -44,11 +54,12 @@
Height="360"
ItemsSource="{x:Bind Pictures}">
<FlipView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<DataTemplate x:DataType="data:HomeBanner">
<Image
HorizontalAlignment="Center"
VerticalAlignment="Center"
Source="{x:Bind Mode=OneTime}"
PointerPressed="Image_PointerPressed"
Source="{Binding picture}"
Stretch="UniformToFill" />
</DataTemplate>
</FlipView.ItemTemplate>
@ -63,6 +74,7 @@
<RelativePanel>
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="随机推荐" />
<AppBarButton
Click="RefreshRandom"
Icon="Refresh"
Label="刷新"
RelativePanel.AlignRightWithPanel="True" />
@ -74,13 +86,14 @@
IsItemClickEnabled="True"
ItemClick="ListAClick"
ItemTemplate="{StaticResource HomePageListItem}"
ItemsSource="{x:Bind conns}"
ItemsSource="{x:Bind ViewModel.randomList}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectionMode="None" />
<RelativePanel>
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="最新发布" />
<AppBarButton
Click="RefreshLatest"
Icon="Refresh"
Label="刷新"
RelativePanel.AlignRightWithPanel="True" />
@ -89,8 +102,9 @@
Grid.Row="2"
Margin="0,0,0,50"
IsItemClickEnabled="True"
ItemClick="ListAClick"
ItemTemplate="{StaticResource HomePageListItem}"
ItemsSource="{x:Bind newlist}"
ItemsSource="{x:Bind ViewModel.latestTimeList}"
SelectionMode="None" />
</StackPanel>

View File

@ -11,6 +11,8 @@ using RustTools.Services;
using RustTools.ViewModels;
using Windows.UI.WindowManagement;
using System.Threading;
using Microsoft.UI.Xaml.Media.Imaging;
using System.Text.RegularExpressions;
namespace RustTools.Views;
public sealed partial class HomePage : Page
{
@ -18,10 +20,7 @@ public sealed partial class HomePage : Page
{
get;
}
public ObservableCollection<Contact> conns = new();
public ObservableCollection<Contact> newlist = new();
public ObservableCollection<string> Pictures { get; } = new ObservableCollection<string>();
public ObservableCollection<HomeBanner.Data> Pictures = new();
public HomePage()
{
ViewModel = App.GetService<HomePageViewModel>();
@ -31,88 +30,14 @@ public sealed partial class HomePage : Page
{
foreach (var item in lunbo.data)
{
Pictures.Add(item.picture);
Pictures.Add(item);
}
}
StartAsync();
ViewModel.random();
ViewModel.Latest();
InitializeComponent();
}
private async Task StartAsync()
{
var v = await wl.postAsync("/php/mod.php?action=random", new string[][]{
new string[] { "number", "6" }});
var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(v);
if (modListResponse != null)
{
conns.Clear();
foreach (var item in modListResponse.Data)
{
//https://rust.coldmint.top
if (item.Icon.Equals(""))
{
item.Icon = "/Assets/image/image.svg";
}
var contact = new Contact(item.Name, item.Description, item.UpdateTime + " " + item.CoinNumber + "次下载")
{
ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top")
};
conns.Add(contact);
}
}
var vv = await wl.postAsync("/php/mod.php?action=list", new string[][]{
new string[] { "sortMode", "latestTime" },
new string[] { "limit", "6" },
new string[] { "tag", "" }});
modListResponse = JsonConvert.DeserializeObject<ModListResponse>(vv);
if (modListResponse != null)
{
newlist.Clear();
foreach (var item in modListResponse.Data)
{
//https://rust.coldmint.top
if (item.Icon.Equals(""))
{
item.Icon = "/Assets/image/image.svg";
}
var contact = new Contact(item.Name, item.Description, item.UpdateTime + " " + item.CoinNumber + "次下载")
{
ImageUrl = item.Icon.Replace("..", "https://rust.coldmint.top")
};
newlist.Add(contact);
}
}
}
public class Contact
{
public string Title
{
get; private set;
}
public string Message
{
get; private set;
}
public string Info
{
get; private set;
}
public string ImageUrl
{
get; set;
}
public Contact(string firstName, string lastName, string company)
{
Title = firstName;
Message = lastName;
Info = company;
}
}
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{
//var height = DisplayArea.Primary.WorkArea.Height;
@ -124,18 +49,72 @@ public sealed partial class HomePage : Page
}
private void ListAClick(object sender, ItemClickEventArgs e)
{
// 获取被点击的项
// 创建一个新的Window实例
Window newWindow = new Window
{
// 将NewPage设置为新Window的内容
Content = new ListViewPage(),
if (e.ClickedItem is not ModData item) { return; }
var newWindow = new ModulePage(item.Id);
newWindow.Activate();
//// 获取点击的列表项的数据
//// 假设 RandomItem 是您的数据模型中的一个类
// 设置新Window的一些属性如标题和大小
Title = "New Page",
};
//// 获取被点击的项
//// 创建一个新的Window实例
//var window = new Window
//{
// // 将NewPage设置为新Window的内容
// Content = new ModulePage(item?.Id),
// 显示新Window
newWindow.Show();
// // 设置新Window的一些属性如标题和大小
// Title =item?.Name,
//};
//window.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
////window.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/创意工坊.svg"));
//// 显示新Window
//window.Show();
}
private void RefreshRandom(object sender,RoutedEventArgs e)
{
ViewModel.random();
}
private void RefreshLatest(object sender, RoutedEventArgs e)
{
ViewModel.Latest();
}
private void Image_PointerPressed(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
{
// 获取点击的 Image 控件
var image = sender as Image;
if (image != null)
{
// 获取 Image 控件的绑定数据上下文
var item = image.DataContext as HomeBanner.Data;
var link1 = item?.link;
if (link1 != null)
{
// 使用正则表达式匹配大括号内的内容
var match = MyRegex().Match(link1);
if (match.Success)
{
var link = match.Groups[1].Value;
Process.Start(new ProcessStartInfo
{
FileName = link,
UseShellExecute = true,
Verb = "open"
});
}
else
{
Debug.WriteLine("No match found.");
}
}
}
}
[GeneratedRegex("\\{(.+?)\\}")]
private static partial Regex MyRegex();
}

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<Page
x:Class="RustTools.Views.ListViewPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:RustTools.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
<Page.Resources>
<DataTemplate x:Key="ContactListViewTemplate" x:DataType="local:HomePage">
<TextBlock
Margin="0,5,0,5"
x:Phase="1"
Text="{x:Bind Name}" />
</DataTemplate>
</Page.Resources>
<Grid>
<ListView
x:Name="BaseExample"
Width="350"
Height="400"
BorderBrush="{ThemeResource SystemControlForegroundBaseMediumLowBrush}"
ItemTemplate="{StaticResource ContactListViewTemplate}" />
</Grid>
</Page>

View File

@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
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;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace RustTools.Views;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ListViewPage : Page
{
public ListViewPage()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<Window
x:Class="RustTools.Views.ModulePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:data="using:RustTools.DataList"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="模组信息"
mc:Ignorable="d">
<Window.SystemBackdrop>
<DesktopAcrylicBackdrop />
</Window.SystemBackdrop>
<Grid x:Name="grid">
<StackPanel
Grid.Row="1"
Height="126"
Margin="16,16,16,16"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Orientation="Horizontal">
<Border
Width="106"
Height="106"
CornerRadius="9">
<Border.Background>
<ImageBrush ImageSource="{Binding Mod.IconUrl}" Stretch="UniformToFill" />
</Border.Background>
</Border>
<StackPanel Margin="16,3,9,3" Orientation="Vertical">
<TextBlock Style="{StaticResource TitleLargeTextBlockStyle}" Text="{Binding Mod.Name}" />
<TextBlock
x:Name="title_b"
Margin="0,3,0,0"
Style="{StaticResource BodyTextBlockStyle}"
Text="加载中" />
<TextBlock
x:Name="title_c"
Margin="0,9,0,0"
Style="{StaticResource BodyTextBlockStyle}"
Text="加载中" />
</StackPanel>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
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 RustTools.muqing;
using Newtonsoft.Json;
using RustTools.DataList;
using RustTools.Core.Helpers;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace RustTools.Views;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ModulePage : Window
{
public ModInfo.Data Mod { get; set; }
public ModulePage(string v)
{
InitializeComponent();
init(v);
}
private async void init(string v)
{
//string json = "\r\n{\"code\":0,\"message\":\"获取成功。\",\"data\":{\"id\":\"585886886883885357567508566896\",\"name\":\"升级模组5.0\",\"describe\":\"。?,。???\",\"icon\":\"\",\"tags\":\"[,。!。]\",\"screenshots\":\"\",\"developer\":\"SDL_13964\",\"link\":\"..\\/user\\/SDL_13964\\/mods\\/585886886883885357567508566896\\/585886886883885357567508566896.rwmod\",\"downloadNumber\":\"366\",\"versionNumber\":\"1\",\"versionName\":\"1.14514\",\"updateTime\":\"2022-07-20 14:20:09\",\"creationTime\":\"2022-07-20 14:20:09\",\"unitNumber\":\"909\",\"hidden\":\"0\",\"coinNumber\":\"1\",\"minVersion\":\"\"}}";
var json = await ApiFox.mod.getInfo("", v);
var a = JsonConvert.DeserializeObject<ModInfo>(json);
if (a != null)
{
Mod = a.data;
if (Mod.IconUrl.Equals(""))
{
Mod.IconUrl = "/Assets/image/image_106.svg";
}
else
{
Mod.IconUrl = Mod.IconUrl.Replace("..", wl.api);
}
gj.sc(Mod.Name);
var l = " | ";
title_b.Text = "单位数" + Mod.UnitNumber + l + Mod.DownloadNumber + "次下载" + l + "版本名称" + Mod.VersionName;
title_c.Text = "发布时间:" + Mod.CreationTime + " 最近更新:" + Mod.UpdateTime;
grid.DataContext = this; // 设置数据上下文
}
}
}

View File

@ -11,31 +11,48 @@ class wl
/// <param name="url">
/// <para>地址</para>
/// </param>
/// <param name="p">
/// <param name="parameters">
/// <para>参数</para>
/// </param>
/// <returns></returns>
public static async Task<string> postAsync(string url, string[][] p)
public static async Task<string?> postAsync(string url, string[][] parameters)
{
var client = new RestClient(api);
var request = new RestRequest(url, Method.Post);
for (var i = 0; i < p.Length; i++)
for (var i = 0; i < parameters.Length; i++)
{
request.AddParameter(p[i][0], p[i][1]);
request.AddParameter(parameters[i][0], parameters[i][1]);
}
var response = await client.ExecuteAsync(request);
if (response != null)
{
var str = response.Content;
if (str == null)
{
return string.Empty;
}
else
{
return str;
}
return str;
}
return string.Empty;
}
return null;
}
/// <summary>
/// 在Thread中向指定的URL发送POST请求并使用提供的参数。
/// </summary>
/// <param name="url">要发送数据的URL。</param>
/// <param name="parameters">包含键值对的参数数组。</param>
/// <returns>服务器响应的字符串如果请求失败则返回null。</returns>
/// <exception cref="T:System.Net.WebException">如果网络请求发生错误,则抛出此异常。</exception>
public static string? post(string url, string[][] parameters)
{
var client = new RestClient(api);
var request = new RestRequest(url, Method.Post);
for (var i = 0; i < parameters.Length; i++)
{
request.AddParameter(parameters[i][0], parameters[i][1]);
}
var response = client.Execute(request);
if (response != null)
{
return response.Content;
}
return null;
}
}