diff --git a/RustTools/ApiFox/user.cs b/RustTools/ApiFox/user.cs
index 279deca..1e36efc 100644
--- a/RustTools/ApiFox/user.cs
+++ b/RustTools/ApiFox/user.cs
@@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using RustTools.muqing;
using RustTools.Views;
+using static IniHelper;
namespace RustTools.ApiFox;
@@ -70,6 +71,12 @@ public class user
return task;
}
+ ///
+ /// 激活用户
+ ///
+ ///
+ ///
+ ///
public static async Task enableAccount(string account, string key)
{
var task = await wl.postAsync("/php/user.php?action=enableAccount", new string[][]
@@ -80,4 +87,43 @@ public class user
return task;
}
+
+ ///
+ /// 修改密码 发送邮箱验证码
+ ///
+ ///
+ ///
+ public static async Task requestChangePassword(string account)
+ {
+ var pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
+ var v = Regex.IsMatch(account, pattern);
+ var task = await wl.postAsync("/php/user.php?action=requestChangePassword", new string[][]
+ {
+ new []{ "account",account},
+ new []{ "isEmail", v.ToString().ToLower()}
+ });
+ return task;
+ }
+
+ ///
+ /// 修改密码
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task changePassword(string account, string newPassword, string code)
+ {
+ var pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
+ var v = Regex.IsMatch(account, pattern);
+ var task = await wl.postAsync("/php/user.php?action=changePassword", new string[][]
+ {
+ new []{ "account",account},
+ new []{ "isEmail", v.ToString().ToLower()},
+ new []{ "code", code},
+ new []{ "newPassword", newPassword}
+ });
+ return task;
+ }
+
}
diff --git a/RustTools/Assets/WindowIcon.ico b/RustTools/Assets/WindowIcon.ico
index b6c9dd1..f66504c 100644
Binary files a/RustTools/Assets/WindowIcon.ico and b/RustTools/Assets/WindowIcon.ico differ
diff --git a/RustTools/MainWindow.xaml.cs b/RustTools/MainWindow.xaml.cs
index 4f1bd48..8b22a21 100644
--- a/RustTools/MainWindow.xaml.cs
+++ b/RustTools/MainWindow.xaml.cs
@@ -14,11 +14,11 @@ public sealed partial class MainWindow : WindowEx
{
InitializeComponent();
gj.SetBackTheme(this);
- AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
- //AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/Icon.ico"));
Content = null;
+ ExtendsContentIntoTitleBar = true;
+ this.SetIcon("Assets/WindowIcon.ico");
+ //AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
Title = "AppDisplayName".GetLocalized();
-
// Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239
dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
settings.ColorValuesChanged += Settings_ColorValuesChanged;
diff --git a/RustTools/RustTools.csproj b/RustTools/RustTools.csproj
index c018940..0e04d26 100644
--- a/RustTools/RustTools.csproj
+++ b/RustTools/RustTools.csproj
@@ -29,8 +29,22 @@
True
Never
D:\RustTools
-
+
+
+
+
+
+
+
+
+
@@ -51,6 +65,8 @@
+
+
Always
@@ -60,5 +76,5 @@
-
+
\ No newline at end of file
diff --git a/RustTools/Themes/LoginPage.xaml b/RustTools/Themes/LoginPage.xaml
index a2e4ee4..6de3903 100644
--- a/RustTools/Themes/LoginPage.xaml
+++ b/RustTools/Themes/LoginPage.xaml
@@ -1,4 +1,5 @@
+
+
@@ -30,6 +35,11 @@
PlaceholderText="密码" />
+
@@ -102,4 +112,4 @@
Subtitle="信息" />
-
+
\ No newline at end of file
diff --git a/RustTools/Themes/LoginPage.xaml.cs b/RustTools/Themes/LoginPage.xaml.cs
index 6ba94a5..1576f57 100644
--- a/RustTools/Themes/LoginPage.xaml.cs
+++ b/RustTools/Themes/LoginPage.xaml.cs
@@ -26,11 +26,11 @@ public sealed partial class LoginPage : UserControl
ZpasswordBox.PasswordChanged += ZPasswordBox_PasswordChanged;
ZpasswordyesBox.PasswordChanged += ZPasswordBox_PasswordChanged;
- ZaccountBox.Text = "muqing1";
- ZnameBox.Text = "muqing153";
- ZpasswordBox.Password = "123456";
- ZpasswordBox.Password= "123456";
- ZemialBox.Text="123456@qq.com";
+ //ZaccountBox.Text = "muqing1";
+ //ZnameBox.Text = "muqing153";
+ //ZpasswordBox.Password = "123456";
+ //ZpasswordBox.Password= "123456";
+ //ZemialBox.Text="123456@qq.com";
}
@@ -41,18 +41,26 @@ public sealed partial class LoginPage : UserControl
///
private void Back_Click(object sender, RoutedEventArgs e)
{
- var storyboard = CreateFadeTransitionStoryboard(enroll_view,login_view);
- storyboard.Begin();
- }
- ///
- /// лע
- ///
- ///
- ///
- private void enroll_Click(object sender, RoutedEventArgs e)
- {
- var storyboard = CreateFadeTransitionStoryboard(login_view, enroll_view);
- storyboard.Begin();
+ var frameworkElement = sender as Button;
+ if (frameworkElement == null)
+ {
+ return;
+ }
+ gj.sc(frameworkElement);
+ if (frameworkElement.Content.ToString()=="ע")
+ {
+ CreateFadeTransitionStoryboard(login_view,enroll_view).Begin();
+ }else if (frameworkElement.Content.ToString() == "һ")
+ {
+ CreateFadeTransitionStoryboard(login_view, RediscoverPassGrid_view).Begin();
+ }
+ else if(enroll_view.Visibility==Visibility.Visible)
+ {
+ CreateFadeTransitionStoryboard(enroll_view, login_view).Begin();
+ }else if (RediscoverPassGrid_view.Visibility == Visibility.Visible)
+ {
+ CreateFadeTransitionStoryboard(RediscoverPassGrid_view, login_view).Begin();
+ }
}
private Storyboard CreateFadeTransitionStoryboard(FrameworkElement fromElement, FrameworkElement toElement)
diff --git a/RustTools/Themes/RediscoverPassGrid.xaml b/RustTools/Themes/RediscoverPassGrid.xaml
new file mode 100644
index 0000000..3993edf
--- /dev/null
+++ b/RustTools/Themes/RediscoverPassGrid.xaml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RustTools/Themes/RediscoverPassGrid.xaml.cs b/RustTools/Themes/RediscoverPassGrid.xaml.cs
new file mode 100644
index 0000000..5f85d53
--- /dev/null
+++ b/RustTools/Themes/RediscoverPassGrid.xaml.cs
@@ -0,0 +1,106 @@
+
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Newtonsoft.Json;
+using RustTools.DataList;
+using WinUIEx.Messaging;
+namespace RustTools.Themes;
+///
+/// һ
+///
+public sealed partial class RediscoverPassGrid : UserControl
+{
+ public event RoutedEventHandler BackClick
+ {
+ add => BackButton.Click += value;
+ remove => BackButton.Click -= value;
+ }
+ public RediscoverPassGrid()
+ {
+ InitializeComponent();
+ accountBox.TextChanged += AccountBox_TextChanged;
+ codeBox.TextChanged += AccountBox_TextChanged;
+ passwordBox.PasswordChanged += PasswordBox_PasswordChanged;
+ passwordyesBox.PasswordChanged += PasswordBox_PasswordChanged;
+ }
+
+ private void AccountBox_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ redisButton.IsEnabled = IsEnabledButton;
+ }
+ private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
+ {
+ redisButton.IsEnabled = IsEnabledButton;
+ }
+
+ ///
+ /// ֤
+ ///
+ ///
+ ///
+ private async void ButtonIcon_Click(object sender, RoutedEventArgs e)
+ {
+ Toast.IsOpen = false;
+ if (accountBox.Text == string.Empty) {
+
+ Toast.IsOpen = true;
+ Toast.Title = "ʾ";
+ Toast.Subtitle = "˺ŲΪ";
+ return;
+ }
+ try
+ {
+ var v = await ApiFox.user.requestChangePassword(accountBox.Text);
+ var message = JsonConvert.DeserializeObject(v);
+ Toast.IsOpen = true;
+ Toast.Title = "ʾ";
+ Toast.Subtitle = message.message;
+ await Task.Delay(millisecondsDelay: 1000);
+ Toast.IsOpen = false;
+ }
+ catch (Exception ex) {
+ Toast.IsOpen = true;
+ Toast.Title = "ʾ";
+ Toast.Subtitle = ex.Message;
+ await Task.Delay(millisecondsDelay: 1000);
+ Toast.IsOpen = false;
+ }
+ }
+
+ public bool IsEnabledButton =>!string.IsNullOrEmpty(accountBox.Text)&&
+ !string.IsNullOrEmpty(passwordBox.Password) &&
+ !string.IsNullOrEmpty(passwordyesBox.Password) &&
+ !string.IsNullOrEmpty(codeBox.Text);
+
+ ///
+ /// һ
+ ///
+ ///
+ ///
+ private async void Button_Click(object sender, RoutedEventArgs e)
+ {
+ Toast.IsOpen = false;
+ try
+ {
+ var v = await ApiFox.user.changePassword(accountBox.Text, passwordBox.Password, codeBox.Text);
+ var message = JsonConvert.DeserializeObject(v);
+ Toast.IsOpen = true;
+ Toast.Title = "ʾ";
+ Toast.Subtitle = message.message;
+ await Task.Delay(millisecondsDelay: 1000);
+ Toast.IsOpen = false;
+
+ }
+ catch (Exception ex)
+ {
+ Toast.IsOpen = true;
+ Toast.Title = "ʾ";
+ Toast.Subtitle = ex.Message;
+ await Task.Delay(millisecondsDelay: 1000);
+ Toast.IsOpen = false;
+ }
+
+ }
+
+ private void RediscoverPassGrid_BackClick(object sender, RoutedEventArgs e) => throw new NotImplementedException();
+}
diff --git a/RustTools/ViewModels/CodeTableViewModel.cs b/RustTools/ViewModels/CodeTableViewModel.cs
new file mode 100644
index 0000000..e1e80cb
--- /dev/null
+++ b/RustTools/ViewModels/CodeTableViewModel.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using CommunityToolkit.Mvvm.ComponentModel;
+
+namespace RustTools.ViewModels;
+
+public class CodeTableViewModel : ObservableRecipient
+{
+
+}
diff --git a/RustTools/Views/CodeTablePage.xaml b/RustTools/Views/CodeTablePage.xaml
new file mode 100644
index 0000000..6e48266
--- /dev/null
+++ b/RustTools/Views/CodeTablePage.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/RustTools/Views/CodeTablePage.xaml.cs b/RustTools/Views/CodeTablePage.xaml.cs
new file mode 100644
index 0000000..9370ed2
--- /dev/null
+++ b/RustTools/Views/CodeTablePage.xaml.cs
@@ -0,0 +1,29 @@
+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.Views;
+///
+/// An empty page that can be used on its own or navigated to within a Frame.
+///
+public sealed partial class CodeTablePage : Page
+{
+ public CodeTablePage()
+ {
+ this.InitializeComponent();
+ }
+}
diff --git a/RustTools/Views/ShellPage.xaml.cs b/RustTools/Views/ShellPage.xaml.cs
index fa3209a..03cdd76 100644
--- a/RustTools/Views/ShellPage.xaml.cs
+++ b/RustTools/Views/ShellPage.xaml.cs
@@ -37,10 +37,11 @@ public sealed partial class ShellPage : Page
// TODO: Set the title bar icon by updating /Assets/WindowIcon.ico.
// A custom title bar is required for full window theme and Mica support.
// https://docs.microsoft.com/windows/apps/develop/title-bar?tabs=winui3#full-customization
- App.MainWindow.ExtendsContentIntoTitleBar = true;
- App.MainWindow.SetTitleBar(AppTitleBar);
- App.MainWindow.Activated += MainWindow_Activated;
- App.MainWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
+ if (App.MainWindow != null)
+ {
+ App.MainWindow.SetTitleBar(AppTitleBar);
+ App.MainWindow.Activated += MainWindow_Activated;
+ }
AppTitleBarText.Text = "app_name".GetLocalized() + " " + "app_version".GetLocalized();
}
@@ -55,7 +56,7 @@ public sealed partial class ShellPage : Page
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
{
- App.AppTitlebar = AppTitleBarText as UIElement;
+ App.AppTitlebar = AppTitleBarText;
}
private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
diff --git a/RustTools/Views/UserPage.xaml.cs b/RustTools/Views/UserPage.xaml.cs
index cf4bab1..018e94a 100644
--- a/RustTools/Views/UserPage.xaml.cs
+++ b/RustTools/Views/UserPage.xaml.cs
@@ -53,10 +53,9 @@ public sealed partial class UserPage : Page
await login(account);
}
}
- catch (Exception ex)
+ catch
{
nulllogin();
- gj.sc(ex);
}
}
private void nulllogin()
@@ -75,8 +74,7 @@ public sealed partial class UserPage : Page
view.Children.Remove((LoginPage)sender);
await login(account);
}
- public string aaa { get; set; } = "aaa";
-
+
private async Task login(string account)
{
var v = await ApiFox.user.SpaceInfo(account);
@@ -86,7 +84,6 @@ public sealed partial class UserPage : Page
var data = userSpaceInfo.Data;
if (data == null) { return; }
data.HeadIcon=data.HeadIcon == string.Empty ? "/Assets/tool.png" : data.HeadIcon.Replace("..", wl.api);
- gj.sc(data.HeadIcon);
userInfo = data;
DataContext = this;
diff --git a/RustTools/WindowUI/ModuleInfoWin.xaml b/RustTools/WindowUI/ModuleInfoWin.xaml
index 07d4dc0..5730dec 100644
--- a/RustTools/WindowUI/ModuleInfoWin.xaml
+++ b/RustTools/WindowUI/ModuleInfoWin.xaml
@@ -12,57 +12,50 @@
Closed="WindowEx_Closed"
SizeChanged="WindowEx_SizeChanged"
mc:Ignorable="d">
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
+ Text="加载中" />
+ Text="加载中" />
-
-
+
+
+ TextWrapping="Wrap" />
+ Visibility="Collapsed" />
-
+
@@ -91,19 +83,19 @@
Name="ReportButton"
Click="AppBarButton_Click"
Icon="ReportHacked"
- Label="举报"/>
-
+ Label="举报" />
+
-
+ Label="支持" />
+
+ Label="下载" />
+ Subtitle="消息" />
-
-
-
-
-
-
diff --git a/RustTools/WindowUI/ModuleInfoWin.xaml.cs b/RustTools/WindowUI/ModuleInfoWin.xaml.cs
index 2aebb5f..6f5a2be 100644
--- a/RustTools/WindowUI/ModuleInfoWin.xaml.cs
+++ b/RustTools/WindowUI/ModuleInfoWin.xaml.cs
@@ -114,68 +114,104 @@ public sealed partial class ModuleInfoWin : WindowEx
break;
case "DownLoadButton":
- var iniHelper = new IniHelper();
- iniHelper.Load(IniHelper.FILE.Config);
- var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
- if (v == string.Empty)
- {
- var dialog = new ContentDialog()
- {
- XamlRoot = grid.XamlRoot,
- Title = "",
- Content = "úģ·",
- SecondaryButtonText = "ȡ"
-
- };
- await dialog.ShowAsync();
- return;
- }
-
- var cancellationTokenSource = new CancellationTokenSource();
- gj.sc("شģ:" + Mod.Link);
- var downloader = new FileDownloader();
- DownloadDialog.XamlRoot = grid.XamlRoot;
- var asyncOperation = DownloadDialog.ShowAsync();
- DownloadDialog.Closing += DownloadDialog_Closing;
- DownloadDialog.SecondaryButtonClick += (a, b) =>
- {
- gj.sc("ɾ");
- cancellationTokenSource.Cancel();
- downloader.Delete();
- };
- try
- {
- var PathMod = Path.Combine(v, Mod.Name);
- if (File.Exists(PathMod + ".rwmod"))
- {
- File.Delete(PathMod + ".rwmod");
- }
- // ļı·
- await downloader.DownloadFileAsync(Mod.Link, PathMod, (totalBytesRead, totalBytes) =>
- {
- DownloadDialogText.Text = $"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete.";
- //Debug.WriteLine($"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete.");
- }, cancellationTokenSource.Token);
- Debug.WriteLine("ļ");
- File.Move(PathMod, PathMod + ".rwmod");
- DownloadDialog.Closing -= DownloadDialog_Closing;
- // ֶضԻ
- DownloadDialog.Hide();
-
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"Error downloading file: {ex.Message}");
- }
- finally
- {
- DownloadDialog.Closing -= DownloadDialog_Closing;
- DownloadDialog.Hide();
- }
+ DownMod();
break;
}
}
+ private async void DownMod()
+ {
+ var iniHelper = new IniHelper();
+ iniHelper.Load(IniHelper.FILE.Config);
+ var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
+ if (v == string.Empty)
+ {
+ var dialog = new ContentDialog()
+ {
+ XamlRoot = grid.XamlRoot,
+ Title = "",
+ Content = "úģ·",
+ SecondaryButtonText = "ȡ"
+
+ };
+ await dialog.ShowAsync();
+ return;
+ }
+
+ var DownloadDialog = new ContentDialog()
+ {
+ XamlRoot = grid.XamlRoot,
+ Title = "",
+ SecondaryButtonText = "ȡ"
+
+ };
+ var stack = new StackPanel();
+ var textBlock = new TextBlock();
+ stack.Children.Add(textBlock);
+ stack.Children.Add(new ProgressBar
+ {
+ Margin = new Thickness(0, 6, 0, 0),
+ IsIndeterminate = true
+ });
+ DownloadDialog.Content =stack;
+ var cancellationTokenSource = new CancellationTokenSource();
+ gj.sc("شģ:" + Mod.Link);
+ var downloader = new FileDownloader();
+ DownloadDialog.XamlRoot = grid.XamlRoot;
+ var asyncOperation = DownloadDialog.ShowAsync();
+ DownloadDialog.Closing += DownloadDialog_Closing;
+ DownloadDialog.SecondaryButtonClick += (a, b) =>
+ {
+ gj.sc("ɾ");
+ cancellationTokenSource.Cancel();
+ downloader.Delete();
+ };
+ try
+ {
+ var name = Mod.Name;//ѷǷַ滻
+ var invalidChars = Path.GetInvalidFileNameChars();
+ foreach (var a in invalidChars)
+ {
+ name = name.Replace(a.ToString(), "_");//ѷǷַ滻
+ }
+ var PathMod = Path.Combine(v, name);
+ if (File.Exists(PathMod + ".rwmod"))
+ {
+ File.Delete(PathMod + ".rwmod");
+ }
+ // ļı·
+ await downloader.DownloadFileAsync(Mod.Link, PathMod, (totalBytesRead, totalBytes) =>
+ {
+ //DownloadDialogText.Text = $"Downloaded {totalBytesRead} of {totalBytes} bytes. {(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}% complete.";
+ textBlock.Text = $"ؽ:{(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}%";
+ }, cancellationTokenSource.Token);
+ Debug.WriteLine("ļ");
+
+ File.Move(PathMod, PathMod + ".rwmod");
+ textBlock.Text = "ļ";
+ DownloadDialog.Closing -= DownloadDialog_Closing;
+ DownloadDialog.IsSecondaryButtonEnabled = false;
+ await Task.Delay(1500);
+ // ֶضԻ
+ DownloadDialog.Hide();
+
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine($"Error downloading file: {ex.Message}");
+ }
+ finally
+ {
+ DownloadDialog.Closing -= DownloadDialog_Closing;
+ DownloadDialog.Hide();
+ }
+ }
+
+ ///
+ /// ײʾȷť
+ ///
+ ///
+ ///
private void Toast_ActionButtonClick(TeachingTip sender, object args)
{
diff --git a/RustTools/muqing/wl.cs b/RustTools/muqing/wl.cs
index fbfbb14..0eacbc8 100644
--- a/RustTools/muqing/wl.cs
+++ b/RustTools/muqing/wl.cs
@@ -96,10 +96,10 @@ class wl
}
}
- //if (IsDelete)
- //{
- // File.Delete(savePath);
- //}
+ if (IsDelete)
+ {
+ File.Delete(savePath);
+ }
}
}