完善主UI界面
This commit is contained in:
parent
10eceac9ee
commit
3f5ef6623e
3
RustTools/Assets/image/image.svg
Normal file
3
RustTools/Assets/image/image.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
height="56px"
|
||||
viewBox="0 -960 960 960" width="56px" 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: 339 B |
56
RustTools/DataList/HomeBanner.cs
Normal file
56
RustTools/DataList/HomeBanner.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace RustTools.DataList
|
||||
{
|
||||
class HomeBanner
|
||||
{
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@
|
|||
<ItemGroup>
|
||||
<None Remove="Views\Concern.xaml" />
|
||||
<None Remove="Views\HomePage.xaml" />
|
||||
<None Remove="Views\ListViewPage.xaml" />
|
||||
<None Remove="Views\RankingPage.xaml" />
|
||||
<None Remove="Views\UserPage.xaml" />
|
||||
</ItemGroup>
|
||||
|
@ -64,6 +65,9 @@
|
|||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
<Page Update="Views\ListViewPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Update="Views\Concern.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
@ -97,4 +101,8 @@
|
|||
<ItemGroup>
|
||||
<PRIResource Remove="Assets\新文件夹\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Assets\image\image_24dp_E8EAED_FILL0_wght400_GRAD0_opsz24 (1).svg" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -10,5 +10,7 @@ public partial class HomePageViewModel : ObservableRecipient
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
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}";
|
||||
}
|
||||
|
|
|
@ -7,17 +7,49 @@
|
|||
xmlns:local="using:RustTools.Views"
|
||||
xmlns:local1="using:Windows.ApplicationModel.Contacts"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
SizeChanged="Page_SizeChanged"
|
||||
mc:Ignorable="d">
|
||||
<ScrollView HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
|
||||
<Page.Resources>
|
||||
<DataTemplate x:Key="HomePageListItem" x:DataType="local:HomePage">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Border
|
||||
Width="56"
|
||||
Height="56"
|
||||
BorderBrush="White"
|
||||
BorderThickness="0"
|
||||
CornerRadius="9">
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="{Binding ImageUrl}" Stretch="UniformToFill" />
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<StackPanel Margin="10,10,10,10" Orientation="Vertical">
|
||||
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Title}" />
|
||||
<TextBlock
|
||||
Width="500"
|
||||
MaxLines="2"
|
||||
Style="{StaticResource BodyStrongTextBlockStyle}"
|
||||
Text="{Binding Message}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="Wrap" />
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Info}" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
<ScrollView HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<FlipView
|
||||
x:Name="Gallery"
|
||||
Height="270"
|
||||
x:Name="Banner"
|
||||
Height="360"
|
||||
ItemsSource="{x:Bind Pictures}">
|
||||
<FlipView.ItemTemplate>
|
||||
<DataTemplate x:DataType="x:String">
|
||||
<Image Source="{x:Bind Mode=OneTime}" Stretch="Fill" />
|
||||
<Image
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Source="{x:Bind Mode=OneTime}"
|
||||
Stretch="UniformToFill" />
|
||||
</DataTemplate>
|
||||
</FlipView.ItemTemplate>
|
||||
</FlipView>
|
||||
|
@ -26,7 +58,7 @@
|
|||
Margin="0,12,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
NumberOfPages="{x:Bind Pictures.Count}"
|
||||
SelectedPageIndex="{x:Bind Path=Gallery.SelectedIndex, Mode=TwoWay}" />
|
||||
SelectedPageIndex="{x:Bind Path=Banner.SelectedIndex, Mode=TwoWay}" />
|
||||
|
||||
<RelativePanel>
|
||||
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="随机推荐" />
|
||||
|
@ -35,28 +67,16 @@
|
|||
Label="刷新"
|
||||
RelativePanel.AlignRightWithPanel="True" />
|
||||
</RelativePanel>
|
||||
|
||||
<ListView
|
||||
x:Name="list"
|
||||
HorizontalAlignment="Stretch"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="ListAClick"
|
||||
ItemTemplate="{StaticResource HomePageListItem}"
|
||||
ItemsSource="{x:Bind conns}"
|
||||
SelectionMode="None">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image
|
||||
Width="56"
|
||||
Height="56"
|
||||
Source="{Binding ImageUrl}" />
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Title}" />
|
||||
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}" Text="{Binding Message}" />
|
||||
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding Info}" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
SelectionMode="None" />
|
||||
|
||||
<RelativePanel>
|
||||
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="最新发布" />
|
||||
|
@ -67,8 +87,14 @@
|
|||
</RelativePanel>
|
||||
<ListView
|
||||
Grid.Row="2"
|
||||
Margin="0,0,0,50"
|
||||
IsItemClickEnabled="True"
|
||||
ItemTemplate="{StaticResource HomePageListItem}"
|
||||
ItemsSource="{x:Bind newlist}"
|
||||
SelectionMode="None" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</Page>
|
||||
|
|
|
@ -1,41 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Newtonsoft.Json;
|
||||
using RustTools.DataList;
|
||||
using RustTools.Services;
|
||||
using RustTools.ViewModels;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage.Streams;
|
||||
using Windows.UI.Xaml;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Windows.UI.WindowManagement;
|
||||
namespace RustTools.Views;
|
||||
public sealed partial class HomePage : Page
|
||||
{
|
||||
public HomePageViewModel ViewModel {
|
||||
public HomePageViewModel ViewModel
|
||||
{
|
||||
get;
|
||||
}
|
||||
public ObservableCollection<Contact> conns = new();
|
||||
public ObservableCollection<Contact> newlist = new();
|
||||
|
||||
public ObservableCollection<string> Pictures { get; } = new ObservableCollection<string>();
|
||||
public HomePage()
|
||||
{
|
||||
ViewModel= App.GetService<HomePageViewModel>();
|
||||
|
||||
Pictures.Add("/Assets/image/a.jpeg");
|
||||
Pictures.Add("/Assets/image/b.jpeg");
|
||||
ViewModel = App.GetService<HomePageViewModel>();
|
||||
//轮播图
|
||||
var lunbo = JsonConvert.DeserializeObject<HomeBanner>(ViewModel.lunbo);
|
||||
if (lunbo != null)
|
||||
{
|
||||
foreach (var item in lunbo.data)
|
||||
{
|
||||
Pictures.Add(item.picture);
|
||||
}
|
||||
}
|
||||
StartAsync();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private void StartAsync()
|
||||
{
|
||||
var modListResponse = JsonConvert.DeserializeObject<ModListResponse>(ViewModel.str);
|
||||
|
@ -43,19 +42,23 @@ public sealed partial class HomePage : Page
|
|||
{
|
||||
return;
|
||||
}
|
||||
conns.Clear();
|
||||
newlist.Clear();
|
||||
foreach (var item in modListResponse.Data)
|
||||
{
|
||||
//https://rust.coldmint.top
|
||||
if (item.Icon.Equals(""))
|
||||
{
|
||||
item.Icon = "/Assets/tool.png";
|
||||
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);
|
||||
newlist.Add(contact);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Contact
|
||||
|
@ -84,5 +87,29 @@ public sealed partial class HomePage : Page
|
|||
}
|
||||
}
|
||||
|
||||
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
//var height = DisplayArea.Primary.WorkArea.Height;
|
||||
//double a = height / 5;
|
||||
//Debug.WriteLine(a);
|
||||
//// 设置FlipView的高度
|
||||
//Banner.Height = a;
|
||||
|
||||
}
|
||||
private void ListAClick(object sender, ItemClickEventArgs e)
|
||||
{
|
||||
// 获取被点击的项
|
||||
// 创建一个新的Window实例
|
||||
Window newWindow = new Window
|
||||
{
|
||||
// 将NewPage设置为新Window的内容
|
||||
Content = new ListViewPage(),
|
||||
|
||||
// 设置新Window的一些属性,如标题和大小
|
||||
Title = "New Page",
|
||||
};
|
||||
|
||||
// 显示新Window
|
||||
newWindow.Show();
|
||||
}
|
||||
}
|
||||
|
|
29
RustTools/Views/ListViewPage.xaml
Normal file
29
RustTools/Views/ListViewPage.xaml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?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>
|
31
RustTools/Views/ListViewPage.xaml.cs
Normal file
31
RustTools/Views/ListViewPage.xaml.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user