From da65694926e447dfa4bd43101fd5d73e20a00109 Mon Sep 17 00:00:00 2001 From: muqing <1966944300@qq.com> Date: Sat, 3 Aug 2024 19:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=E5=8A=A8=E6=80=81=E7=9A=84UI=E5=86=99?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=EF=BC=8C=E5=96=9D=E4=B8=80=E6=9D=AF=E5=92=96?= =?UTF-8?q?=E5=95=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RustTools/App.xaml | 27 +++++- RustTools/App.xaml.cs | 7 +- RustTools/DataList/CommunityList.cs | 111 ++++++++++++++++++++++ RustTools/Package.appxmanifest | 6 +- RustTools/RustTools.csproj | 21 +++- RustTools/Services/PageService.cs | 2 +- RustTools/Strings/zh-cn/Resources.resw | 2 +- RustTools/Styles/ItemView.xaml | 59 ++++++++++++ RustTools/ViewModels/ConcernViewModel.cs | 88 ++++++++++++++++- RustTools/ViewModels/HomePageViewModel.cs | 1 - RustTools/ViewModels/MovingInfo.cs | 18 ++++ RustTools/Views/Concern.xaml | 15 --- RustTools/Views/Concern.xaml.cs | 32 ------- RustTools/Views/ConcernPage.xaml | 48 ++++++++++ RustTools/Views/ConcernPage.xaml.cs | 59 ++++++++++++ RustTools/Views/RankingPage.xaml.cs | 3 + RustTools/Views/SettingsPage.xaml.cs | 1 + RustTools/muqing/IniHelper.cs | 14 ++- RustTools/muqing/gj.cs | 2 +- RustTools/muqing/wj.cs | 8 +- 20 files changed, 454 insertions(+), 70 deletions(-) create mode 100644 RustTools/DataList/CommunityList.cs create mode 100644 RustTools/Styles/ItemView.xaml create mode 100644 RustTools/ViewModels/MovingInfo.cs delete mode 100644 RustTools/Views/Concern.xaml delete mode 100644 RustTools/Views/Concern.xaml.cs create mode 100644 RustTools/Views/ConcernPage.xaml create mode 100644 RustTools/Views/ConcernPage.xaml.cs diff --git a/RustTools/App.xaml b/RustTools/App.xaml index 61d7f6b..e89d519 100644 --- a/RustTools/App.xaml +++ b/RustTools/App.xaml @@ -1,7 +1,9 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="using:RustTools.Views" + xmlns:zy="using:RustTools.DataList"> @@ -9,7 +11,30 @@ + + + + + + + + + + + + + + + diff --git a/RustTools/App.xaml.cs b/RustTools/App.xaml.cs index 179e20a..4cda49c 100644 --- a/RustTools/App.xaml.cs +++ b/RustTools/App.xaml.cs @@ -16,6 +16,8 @@ using Windows.ApplicationModel.Activation; using Windows.Storage; using Microsoft.UI.Xaml.Controls; using Microsoft.Windows.AppLifecycle; +using Windows.ApplicationModel; +using Windows.Management.Core; namespace RustTools; @@ -49,9 +51,8 @@ public partial class App : Microsoft.UI.Xaml.Application public App() { - InitializeComponent(); + InitializeComponent(); // 注册激活事件处理程序 - Host = Microsoft.Extensions.Hosting.Host. CreateDefaultBuilder(). UseContentRoot(AppContext.BaseDirectory). @@ -81,7 +82,7 @@ public partial class App : Microsoft.UI.Xaml.Application services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/RustTools/DataList/CommunityList.cs b/RustTools/DataList/CommunityList.cs new file mode 100644 index 0000000..67d57a5 --- /dev/null +++ b/RustTools/DataList/CommunityList.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.ObjectModel; +using Newtonsoft.Json; + +public class CommunityList +{ + [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("account")] + public string Account + { + get; set; + } + + [JsonProperty("cover")] + public string Cover + { + get; set; + } + + [JsonProperty("introduce")] + public string Introduce + { + get; set; + } + + [JsonProperty("fans")] + public string Fans + { + get; set; + } + + [JsonProperty("follower")] + public string Follower + { + get; set; + } + + [JsonProperty("praise")] + public string Praise + { + get; set; + } + + [JsonProperty("userName")] + public string UserName + { + get; set; + } + + [JsonProperty("headIcon")] + public string HeadIcon + { + get; set; + } + + [JsonProperty("email")] + public string Email + { + get; set; + } + + [JsonProperty("permission")] + public string Permission + { + get; set; + } + + [JsonProperty("loginTime")] + public string LoginTime + { + get; set; + } + + [JsonProperty("gender")] + public string Gender + { + get; set; + } + + [JsonProperty("enable")] + public bool Enable + { + get; set; + } + + [JsonProperty("dynamicColor")] + public string DynamicColor + { + get; set; + } + + } +} diff --git a/RustTools/Package.appxmanifest b/RustTools/Package.appxmanifest index 13c619b..c722b00 100644 --- a/RustTools/Package.appxmanifest +++ b/RustTools/Package.appxmanifest @@ -12,14 +12,14 @@ RustTools - 19669 + muqing Assets\res\StoreLogo.png @@ -74,6 +74,8 @@ + + diff --git a/RustTools/RustTools.csproj b/RustTools/RustTools.csproj index f319a17..4d9850f 100644 --- a/RustTools/RustTools.csproj +++ b/RustTools/RustTools.csproj @@ -6,7 +6,6 @@ RustTools x86;x64;arm64 win10-x86;win10-x64;win10-arm64 - Properties\PublishProfiles\win10-$(Platform).pubxml enable enable true @@ -17,12 +16,25 @@ Assets\WindowIcon.ico README.md zh-cn + + + True + True + 3386EC79D3BB9691D0A8DA634167500B242E109D + SHA256 + False + False + True + Never + C:\\RustTools + D:\RustTools - + + @@ -57,13 +69,16 @@ True \ + + MSBuild:Compile + MSBuild:Compile MSBuild:Compile - + MSBuild:Compile diff --git a/RustTools/Services/PageService.cs b/RustTools/Services/PageService.cs index 7cc087c..27b4f55 100644 --- a/RustTools/Services/PageService.cs +++ b/RustTools/Services/PageService.cs @@ -17,7 +17,7 @@ public class PageService : IPageService //Configure(); Configure(); - Configure(); + Configure(); Configure(); Configure(); diff --git a/RustTools/Strings/zh-cn/Resources.resw b/RustTools/Strings/zh-cn/Resources.resw index 1d6cb45..8f606d6 100644 --- a/RustTools/Strings/zh-cn/Resources.resw +++ b/RustTools/Strings/zh-cn/Resources.resw @@ -160,7 +160,7 @@ Test - 关注 + 动态 主页 diff --git a/RustTools/Styles/ItemView.xaml b/RustTools/Styles/ItemView.xaml new file mode 100644 index 0000000..8835a41 --- /dev/null +++ b/RustTools/Styles/ItemView.xaml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RustTools/ViewModels/ConcernViewModel.cs b/RustTools/ViewModels/ConcernViewModel.cs index 6f44cf4..355bc9a 100644 --- a/RustTools/ViewModels/ConcernViewModel.cs +++ b/RustTools/ViewModels/ConcernViewModel.cs @@ -1,10 +1,96 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using System.Collections.ObjectModel; +using CommunityToolkit.Mvvm.ComponentModel; +using Newtonsoft.Json; +using RustTools.DataList; +using RustTools.muqing; +using Windows.System; namespace RustTools.ViewModels; public partial class ConcernViewModel : ObservableRecipient { + public ObservableCollection communitylist = new(); + public ObservableCollection MovingInfoList = new(); + private readonly string json = @" + { + ""code"": 0, + ""message"": ""获取成功,共3条记录"", + ""data"": [ + { + ""account"": ""offical"", + ""cover"": ""../user/offical/cover.png"", + ""introduce"": null, + ""fans"": ""64"", + ""follower"": ""5"", + ""praise"": ""0"", + ""userName"": ""铁锈助手官方"", + ""headIcon"": ""http://rust.coldmint.top/user/offical/icon.png"", + ""email"": ""2923268971@qq.com"", + ""permission"": ""2"", + ""loginTime"": ""2023-10-21 22:28:18"", + ""gender"": ""1"", + ""enable"": ""true"", + ""dynamicColor"": ""null"" + }, + { + ""account"": ""coldmint"", + ""cover"": ""http://rust.coldmint.top/user/coldmint/covers/181d019f-7cb7-9c07-389e-5a78b98eea54.png"", + ""introduce"": ""我是薄荷老师。”"", + ""fans"": ""141"", + ""follower"": ""13"", + ""praise"": ""0"", + ""userName"": ""薄荷今天吃什么?"", + ""headIcon"": ""https://rust.coldmint.top/user/coldmint/icons/4006dc55-9101-39cc-7076-34c4b32924d5.png"", + ""email"": ""cold_mint@qq.com"", + ""permission"": ""1"", + ""loginTime"": ""2024-08-02 22:04:48"", + ""gender"": ""-1"", + ""enable"": ""true"", + ""dynamicColor"": ""null"" + }, + { + ""account"": ""muqing"", + ""cover"": ""../user/muqing/covers/d4083a79-1e7f-d3bc-5944-ae9bce0d6714.png"", + ""introduce"": ""nihao"", + ""fans"": ""1"", + ""follower"": ""1"", + ""praise"": ""0"", + ""userName"": ""薄荷是我的老婆"", + ""headIcon"": ""../user/muqing/icons/cf0582bb-584c-176f-098b-a9a95af22a44.png"", + ""email"": ""2583089389@qq.com"", + ""permission"": ""3"", + ""loginTime"": ""2024-04-18 14:08:22"", + ""gender"": ""1"", + ""enable"": ""true"", + ""dynamicColor"": ""null"" + } + ] + }"; public ConcernViewModel() { + + var response = JsonConvert.DeserializeObject(json); + var a = new CommunityList.Data + { + UserName = "全部", + HeadIcon = "/Assets/tool.png" + }; + communitylist.Add(a); + foreach (var item in response.data) + { + //item.UserName + item.HeadIcon= item.HeadIcon.Replace("..", wl.api); + communitylist.Add(item); + communitylist.Add(item); + communitylist.Add(item); + } + + MovingInfoList.Add(new MovingInfo.Data("123123")); + MovingInfoList.Add(new MovingInfo.Data("123123")); + MovingInfoList.Add(new MovingInfo.Data("123123")); + MovingInfoList.Add(new MovingInfo.Data("123123")); + MovingInfoList.Add(new MovingInfo.Data("123123")); + MovingInfoList.Add(new MovingInfo.Data("123123")); + MovingInfoList.Add(new MovingInfo.Data("123123")); } } diff --git a/RustTools/ViewModels/HomePageViewModel.cs b/RustTools/ViewModels/HomePageViewModel.cs index 0889181..8a08719 100644 --- a/RustTools/ViewModels/HomePageViewModel.cs +++ b/RustTools/ViewModels/HomePageViewModel.cs @@ -14,7 +14,6 @@ public partial class HomePageViewModel : ObservableRecipient { } - public async void random() { var modListResponse = JsonConvert.DeserializeObject(await ApiFox.mod.random()); diff --git a/RustTools/ViewModels/MovingInfo.cs b/RustTools/ViewModels/MovingInfo.cs new file mode 100644 index 0000000..d4a51f4 --- /dev/null +++ b/RustTools/ViewModels/MovingInfo.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RustTools.ViewModels; +public class MovingInfo +{ + public class Data + { + public string name; + public Data(string name) { + this.name = name; + } + + } +} diff --git a/RustTools/Views/Concern.xaml b/RustTools/Views/Concern.xaml deleted file mode 100644 index 8237210..0000000 --- a/RustTools/Views/Concern.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - diff --git a/RustTools/Views/Concern.xaml.cs b/RustTools/Views/Concern.xaml.cs deleted file mode 100644 index 2fc4f8d..0000000 --- a/RustTools/Views/Concern.xaml.cs +++ /dev/null @@ -1,32 +0,0 @@ -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 RustTools.ViewModels; -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.Views; -/// -/// An empty page that can be used on its own or navigated to within a Frame. -/// -public sealed partial class Concern : Page -{ - public ConcernViewModel ConcernViewModel { get; set; } - public Concern() - { - ConcernViewModel = App.GetService(); - InitializeComponent(); - } -} diff --git a/RustTools/Views/ConcernPage.xaml b/RustTools/Views/ConcernPage.xaml new file mode 100644 index 0000000..6a83137 --- /dev/null +++ b/RustTools/Views/ConcernPage.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + diff --git a/RustTools/Views/ConcernPage.xaml.cs b/RustTools/Views/ConcernPage.xaml.cs new file mode 100644 index 0000000..81e3789 --- /dev/null +++ b/RustTools/Views/ConcernPage.xaml.cs @@ -0,0 +1,59 @@ +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 RustTools.muqing; +using RustTools.ViewModels; +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.Views; + +/// +/// ̬ +/// +public sealed partial class ConcernPage : Page +{ + public ConcernViewModel ViewModels { get; set; } + public ConcernPage() + { + ViewModels = App.GetService(); + InitializeComponent(); + } + + private void ItemsView_ItemInvoked(ItemsView sender, ItemsViewItemInvokedEventArgs args) + { + + } + + + + private void Page_SizeChanged(object sender, SizeChangedEventArgs e) + { + + var height = ActualHeight; // ȷʹҳʵʸ߶ + + // ǷΪЧֵ + if (!double.IsNaN(height) && !double.IsInfinity(height) && height > 16) + { + ListViewA.Height = height - 16; + ListViewB.Height = height - 16; + } + else + { + ListViewA.Height = 500; // ʵĬֵ + ListViewB.Height = 500; // ʵĬֵ + } + } +} diff --git a/RustTools/Views/RankingPage.xaml.cs b/RustTools/Views/RankingPage.xaml.cs index c432aac..b818610 100644 --- a/RustTools/Views/RankingPage.xaml.cs +++ b/RustTools/Views/RankingPage.xaml.cs @@ -18,6 +18,9 @@ using RustTools.ViewModels; // and more about our project templates, see: http://aka.ms/winui-project-info. namespace RustTools.Views; +/// +/// +/// public sealed partial class RankingPage : Page { public RankingViewModel ViewModel diff --git a/RustTools/Views/SettingsPage.xaml.cs b/RustTools/Views/SettingsPage.xaml.cs index 0e0a9a7..a9e7c62 100644 --- a/RustTools/Views/SettingsPage.xaml.cs +++ b/RustTools/Views/SettingsPage.xaml.cs @@ -43,6 +43,7 @@ public sealed partial class SettingsPage : Page case "Mica": BackgroundRadioButtons.SelectedIndex = 3; break; + default: BackgroundRadioButtons.SelectedIndex = 0; break; } BackgroundRadioButtons.SelectionChanged += BackgroundColor_SelectionChanged; ModFileUrlText.Text = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl); diff --git a/RustTools/muqing/IniHelper.cs b/RustTools/muqing/IniHelper.cs index 9bca65e..9bb0deb 100644 --- a/RustTools/muqing/IniHelper.cs +++ b/RustTools/muqing/IniHelper.cs @@ -29,7 +29,7 @@ public class IniHelper public const string MapsFileUrl = "MapsFileUrl"; } - private string filePath; + private string filePath = string.Empty; public IniHelper() { @@ -58,15 +58,19 @@ public class IniHelper /// /// /// - public void Load(string filePath) + public void Load(string a) { - this.filePath = filePath; - if (!File.Exists(filePath)) + filePath = a; + if (!File.Exists(a)) { - File.Create(filePath); + File.Create(a); return; //throw new FileNotFoundException("The specified file does not exist.", filePath); } + if (filePath == null || filePath == string.Empty) + { + return; + } var lines = File.ReadAllLines(filePath); string? currentSection = null; diff --git a/RustTools/muqing/gj.cs b/RustTools/muqing/gj.cs index 7c97f9c..a0c4496 100644 --- a/RustTools/muqing/gj.cs +++ b/RustTools/muqing/gj.cs @@ -41,7 +41,7 @@ class gj /// /// 设置window窗口适配器 主题颜色 /// - public static void SetBackTheme(WindowEx windowEx) + public static async void SetBackTheme(WindowEx windowEx) { var iniHelper = new IniHelper(); iniHelper.Load(IniHelper.FILE.Config); diff --git a/RustTools/muqing/wj.cs b/RustTools/muqing/wj.cs index a01f399..35fe2a2 100644 --- a/RustTools/muqing/wj.cs +++ b/RustTools/muqing/wj.cs @@ -1,18 +1,18 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using Windows.Storage; namespace RustTools.muqing; class wj { //存储主要文件的路径 - public const string CD = "D:\\抓包"; + public static string CD = ApplicationData.Current.LocalFolder.Path; //缓存路径 public const string Cache = ""; - //不知道为什么会保存到这里的路径 - //C:\Users\账号\AppData\Local\VirtualStore\Windows\SysWOW64 - public const string CachePath= "C:/Users/19669/AppData/Local/VirtualStore/Windows/SysWOW64"; + //不知道为什么会保存到这里的路径 废弃了 , 找到了新的文件夹路径 + //public const string CachePath= "C:/Users/账号/AppData/Local/VirtualStore/Windows/SysWOW64"; /// /// 存储文件名字的路径