修复BUG,添加找回密码
This commit is contained in:
parent
b9b309b123
commit
41d4624315
|
@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using RustTools.muqing;
|
using RustTools.muqing;
|
||||||
using RustTools.Views;
|
using RustTools.Views;
|
||||||
|
using static IniHelper;
|
||||||
|
|
||||||
namespace RustTools.ApiFox;
|
namespace RustTools.ApiFox;
|
||||||
|
|
||||||
|
@ -70,6 +71,12 @@ public class user
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 激活用户
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static async Task<string> enableAccount(string account, string key)
|
public static async Task<string> enableAccount(string account, string key)
|
||||||
{
|
{
|
||||||
var task = await wl.postAsync("/php/user.php?action=enableAccount", new string[][]
|
var task = await wl.postAsync("/php/user.php?action=enableAccount", new string[][]
|
||||||
|
@ -80,4 +87,43 @@ public class user
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改密码 发送邮箱验证码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<string> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改密码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <param name="newPassword"></param>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<string> 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 206 KiB After Width: | Height: | Size: 148 KiB |
|
@ -14,11 +14,11 @@ public sealed partial class MainWindow : WindowEx
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
gj.SetBackTheme(this);
|
gj.SetBackTheme(this);
|
||||||
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
|
|
||||||
//AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/Icon.ico"));
|
|
||||||
Content = null;
|
Content = null;
|
||||||
|
ExtendsContentIntoTitleBar = true;
|
||||||
|
this.SetIcon("Assets/WindowIcon.ico");
|
||||||
|
//AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
|
||||||
Title = "AppDisplayName".GetLocalized();
|
Title = "AppDisplayName".GetLocalized();
|
||||||
|
|
||||||
// Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239
|
// Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239
|
||||||
dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
|
dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
|
||||||
settings.ColorValuesChanged += Settings_ColorValuesChanged;
|
settings.ColorValuesChanged += Settings_ColorValuesChanged;
|
||||||
|
|
|
@ -29,8 +29,22 @@
|
||||||
<GenerateTestArtifacts>True</GenerateTestArtifacts>
|
<GenerateTestArtifacts>True</GenerateTestArtifacts>
|
||||||
<AppxBundle>Never</AppxBundle>
|
<AppxBundle>Never</AppxBundle>
|
||||||
<AppxPackageDir>D:\RustTools</AppxPackageDir>
|
<AppxPackageDir>D:\RustTools</AppxPackageDir>
|
||||||
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="RustTools_TemporaryKey.pfx" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="RustTools_TemporaryKey.pfx" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<!--<Target Name="RemoveFoldersWithMuiFiles" AfterTargets="Build">
|
||||||
|
<ItemGroup>
|
||||||
|
<RemovingFiles Include="$(OutDir)*\*.mui" Exclude="$(OutDir)en-us\*.mui" />
|
||||||
|
<RemovingFolders Include="@(RemovingFiles->'%(RootDir)%(Directory)')" />
|
||||||
|
</ItemGroup>
|
||||||
|
<RemoveDir Directories="@(RemovingFolders)" />
|
||||||
|
</Target>-->
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
||||||
|
@ -51,6 +65,8 @@
|
||||||
|
|
||||||
<Manifest Include="$(ApplicationManifest)" />
|
<Manifest Include="$(ApplicationManifest)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!--在vs code 中必须加上不然没有任何图标-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Assets\**">
|
<Content Include="Assets\**">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
||||||
<UserControl
|
<UserControl
|
||||||
x:Class="RustTools.Themes.LoginPage"
|
x:Class="RustTools.Themes.LoginPage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
@ -16,6 +17,10 @@
|
||||||
Background="{StaticResource CardStrokeColorDefault}"
|
Background="{StaticResource CardStrokeColorDefault}"
|
||||||
CornerRadius="13">
|
CornerRadius="13">
|
||||||
<Grid MinWidth="290" HorizontalAlignment="Center">
|
<Grid MinWidth="290" HorizontalAlignment="Center">
|
||||||
|
<local:RediscoverPassGrid
|
||||||
|
x:Name="RediscoverPassGrid_view"
|
||||||
|
BackClick="Back_Click"
|
||||||
|
Visibility="Collapsed" />
|
||||||
<StackPanel x:Name="login_view">
|
<StackPanel x:Name="login_view">
|
||||||
<TextBlock HorizontalAlignment="Center" Text="登陆" />
|
<TextBlock HorizontalAlignment="Center" Text="登陆" />
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
@ -30,6 +35,11 @@
|
||||||
PlaceholderText="密码" />
|
PlaceholderText="密码" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
Margin="0,0,36,0"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Click="Back_Click"
|
||||||
|
Content="找回密码" />
|
||||||
<Button
|
<Button
|
||||||
Name="loginButton"
|
Name="loginButton"
|
||||||
Width="100"
|
Width="100"
|
||||||
|
@ -40,7 +50,7 @@
|
||||||
Style="{StaticResource AccentButtonStyle}" />
|
Style="{StaticResource AccentButtonStyle}" />
|
||||||
<Button
|
<Button
|
||||||
Margin="0,0,0,0"
|
Margin="0,0,0,0"
|
||||||
Click="enroll_Click"
|
Click="Back_Click"
|
||||||
Content="注册" />
|
Content="注册" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<CheckBox x:Name="agreementCheck">
|
<CheckBox x:Name="agreementCheck">
|
||||||
|
|
|
@ -26,11 +26,11 @@ public sealed partial class LoginPage : UserControl
|
||||||
ZpasswordBox.PasswordChanged += ZPasswordBox_PasswordChanged;
|
ZpasswordBox.PasswordChanged += ZPasswordBox_PasswordChanged;
|
||||||
ZpasswordyesBox.PasswordChanged += ZPasswordBox_PasswordChanged;
|
ZpasswordyesBox.PasswordChanged += ZPasswordBox_PasswordChanged;
|
||||||
|
|
||||||
ZaccountBox.Text = "muqing1";
|
//ZaccountBox.Text = "muqing1";
|
||||||
ZnameBox.Text = "muqing153";
|
//ZnameBox.Text = "muqing153";
|
||||||
ZpasswordBox.Password = "123456";
|
//ZpasswordBox.Password = "123456";
|
||||||
ZpasswordBox.Password= "123456";
|
//ZpasswordBox.Password= "123456";
|
||||||
ZemialBox.Text="123456@qq.com";
|
//ZemialBox.Text="123456@qq.com";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,18 +41,26 @@ public sealed partial class LoginPage : UserControl
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void Back_Click(object sender, RoutedEventArgs e)
|
private void Back_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var storyboard = CreateFadeTransitionStoryboard(enroll_view,login_view);
|
var frameworkElement = sender as Button;
|
||||||
storyboard.Begin();
|
if (frameworkElement == null)
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Çл»µ½×¢²á
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void enroll_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
{
|
||||||
var storyboard = CreateFadeTransitionStoryboard(login_view, enroll_view);
|
return;
|
||||||
storyboard.Begin();
|
}
|
||||||
|
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)
|
private Storyboard CreateFadeTransitionStoryboard(FrameworkElement fromElement, FrameworkElement toElement)
|
||||||
|
|
58
RustTools/Themes/RediscoverPassGrid.xaml
Normal file
58
RustTools/Themes/RediscoverPassGrid.xaml
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<UserControl
|
||||||
|
x:Class="RustTools.Themes.RediscoverPassGrid"
|
||||||
|
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.Themes"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<StackPanel>
|
||||||
|
<local:ButtonIcon x:Name="BackButton" Glyph="" />
|
||||||
|
<TextBlock HorizontalAlignment="Center" Text="找回密码" />
|
||||||
|
<StackPanel>
|
||||||
|
<TextBox
|
||||||
|
Name="accountBox"
|
||||||
|
Margin="0,16,0,16"
|
||||||
|
InputScope="AlphanumericPin"
|
||||||
|
PlaceholderText="账号" />
|
||||||
|
<PasswordBox
|
||||||
|
Name="passwordBox"
|
||||||
|
Margin="0,0,0,16"
|
||||||
|
PlaceholderText="密码" />
|
||||||
|
<PasswordBox
|
||||||
|
Name="passwordyesBox"
|
||||||
|
Margin="0,0,0,16"
|
||||||
|
PlaceholderText="确认密码" />
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBox
|
||||||
|
Name="codeBox"
|
||||||
|
MinWidth="260"
|
||||||
|
Margin="0,0,0,16"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
MaxLength="6"
|
||||||
|
PlaceholderText="邮箱验证码" />
|
||||||
|
<local:ButtonIcon
|
||||||
|
Margin="6,0,0,16"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Click="ButtonIcon_Click"
|
||||||
|
Glyph=""
|
||||||
|
ToolTipService.ToolTip="发送" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
<Button
|
||||||
|
x:Name="redisButton"
|
||||||
|
Margin="0,0,0,0"
|
||||||
|
Click="Button_Click"
|
||||||
|
Content="找回密码"
|
||||||
|
IsEnabled="False" />
|
||||||
|
</StackPanel>
|
||||||
|
<TeachingTip Name="Toast" CloseButtonContent="关闭" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
106
RustTools/Themes/RediscoverPassGrid.xaml.cs
Normal file
106
RustTools/Themes/RediscoverPassGrid.xaml.cs
Normal file
|
@ -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;
|
||||||
|
/// <summary>
|
||||||
|
/// 找回密码
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 发送验证码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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<DataList.Message>(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);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 找回密码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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<DataList.Message>(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();
|
||||||
|
}
|
13
RustTools/ViewModels/CodeTableViewModel.cs
Normal file
13
RustTools/ViewModels/CodeTableViewModel.cs
Normal file
|
@ -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
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
13
RustTools/Views/CodeTablePage.xaml
Normal file
13
RustTools/Views/CodeTablePage.xaml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Page
|
||||||
|
x:Class="RustTools.Views.CodeTablePage"
|
||||||
|
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">
|
||||||
|
|
||||||
|
<Grid />
|
||||||
|
</Page>
|
29
RustTools/Views/CodeTablePage.xaml.cs
Normal file
29
RustTools/Views/CodeTablePage.xaml.cs
Normal file
|
@ -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;
|
||||||
|
/// <summary>
|
||||||
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||||
|
/// </summary>
|
||||||
|
public sealed partial class CodeTablePage : Page
|
||||||
|
{
|
||||||
|
public CodeTablePage()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,10 +37,11 @@ public sealed partial class ShellPage : Page
|
||||||
// TODO: Set the title bar icon by updating /Assets/WindowIcon.ico.
|
// TODO: Set the title bar icon by updating /Assets/WindowIcon.ico.
|
||||||
// A custom title bar is required for full window theme and Mica support.
|
// 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
|
// https://docs.microsoft.com/windows/apps/develop/title-bar?tabs=winui3#full-customization
|
||||||
App.MainWindow.ExtendsContentIntoTitleBar = true;
|
if (App.MainWindow != null)
|
||||||
|
{
|
||||||
App.MainWindow.SetTitleBar(AppTitleBar);
|
App.MainWindow.SetTitleBar(AppTitleBar);
|
||||||
App.MainWindow.Activated += MainWindow_Activated;
|
App.MainWindow.Activated += MainWindow_Activated;
|
||||||
App.MainWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
|
}
|
||||||
AppTitleBarText.Text = "app_name".GetLocalized() + " " + "app_version".GetLocalized();
|
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)
|
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
|
||||||
{
|
{
|
||||||
App.AppTitlebar = AppTitleBarText as UIElement;
|
App.AppTitlebar = AppTitleBarText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
|
private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
|
||||||
|
|
|
@ -53,10 +53,9 @@ public sealed partial class UserPage : Page
|
||||||
await login(account);
|
await login(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch
|
||||||
{
|
{
|
||||||
nulllogin();
|
nulllogin();
|
||||||
gj.sc(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void nulllogin()
|
private void nulllogin()
|
||||||
|
@ -75,7 +74,6 @@ public sealed partial class UserPage : Page
|
||||||
view.Children.Remove((LoginPage)sender);
|
view.Children.Remove((LoginPage)sender);
|
||||||
await login(account);
|
await login(account);
|
||||||
}
|
}
|
||||||
public string aaa { get; set; } = "aaa";
|
|
||||||
|
|
||||||
private async Task login(string account)
|
private async Task login(string account)
|
||||||
{
|
{
|
||||||
|
@ -86,7 +84,6 @@ public sealed partial class UserPage : Page
|
||||||
var data = userSpaceInfo.Data;
|
var data = userSpaceInfo.Data;
|
||||||
if (data == null) { return; }
|
if (data == null) { return; }
|
||||||
data.HeadIcon=data.HeadIcon == string.Empty ? "/Assets/tool.png" : data.HeadIcon.Replace("..", wl.api);
|
data.HeadIcon=data.HeadIcon == string.Empty ? "/Assets/tool.png" : data.HeadIcon.Replace("..", wl.api);
|
||||||
gj.sc(data.HeadIcon);
|
|
||||||
userInfo = data;
|
userInfo = data;
|
||||||
|
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
|
|
|
@ -12,57 +12,50 @@
|
||||||
Closed="WindowEx_Closed"
|
Closed="WindowEx_Closed"
|
||||||
SizeChanged="WindowEx_SizeChanged"
|
SizeChanged="WindowEx_SizeChanged"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Grid x:Name="grid"
|
<Grid x:Name="grid" Padding="16,36,16,10">
|
||||||
Padding="16,36,16,10">
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions/>
|
<Grid.ColumnDefinitions />
|
||||||
<StackPanel Grid.Row="0"
|
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||||
Orientation="Horizontal">
|
|
||||||
<Border
|
<Border
|
||||||
Width="106"
|
Width="106"
|
||||||
Height="106"
|
Height="106"
|
||||||
CornerRadius="9">
|
CornerRadius="9">
|
||||||
<Border.Background>
|
<Border.Background>
|
||||||
<ImageBrush ImageSource="{Binding Mod.IconUrl}"
|
<ImageBrush ImageSource="{Binding Mod.IconUrl}" Stretch="UniformToFill" />
|
||||||
Stretch="UniformToFill"/>
|
|
||||||
</Border.Background>
|
</Border.Background>
|
||||||
</Border>
|
</Border>
|
||||||
<StackPanel Margin="16,3,9,3"
|
<StackPanel Margin="16,3,9,3" Orientation="Vertical">
|
||||||
Orientation="Vertical">
|
<TextBlock Style="{StaticResource TitleLargeTextBlockStyle}" Text="{Binding Mod.Name}" />
|
||||||
<TextBlock Style="{StaticResource TitleLargeTextBlockStyle}"
|
|
||||||
Text="{Binding Mod.Name}"/>
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="title_b"
|
x:Name="title_b"
|
||||||
Margin="0,3,0,0"
|
Margin="0,3,0,0"
|
||||||
Style="{StaticResource BodyTextBlockStyle}"
|
Style="{StaticResource BodyTextBlockStyle}"
|
||||||
Text="加载中"/>
|
Text="加载中" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="title_c"
|
x:Name="title_c"
|
||||||
Margin="0,9,0,0"
|
Margin="0,9,0,0"
|
||||||
Style="{StaticResource BodyTextBlockStyle}"
|
Style="{StaticResource BodyTextBlockStyle}"
|
||||||
Text="加载中"/>
|
Text="加载中" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ScrollView Grid.Row="1">
|
<ScrollView Grid.Row="1">
|
||||||
<StackPanel Margin="0,26,0,0"
|
<StackPanel Margin="0,26,0,0" Orientation="Vertical">
|
||||||
Orientation="Vertical">
|
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="介绍" />
|
||||||
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}"
|
|
||||||
Text="介绍"/>
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="DescriptionText"
|
x:Name="DescriptionText"
|
||||||
Padding="6,6,6,6"
|
Padding="6,6,6,6"
|
||||||
Style="{StaticResource BodyTextBlockStyle}"
|
Style="{StaticResource BodyTextBlockStyle}"
|
||||||
Text="{Binding Mod.Description}"
|
Text="{Binding Mod.Description}"
|
||||||
TextWrapping="Wrap"/>
|
TextWrapping="Wrap" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="fliptext"
|
x:Name="fliptext"
|
||||||
Style="{StaticResource SubtitleTextBlockStyle}"
|
Style="{StaticResource SubtitleTextBlockStyle}"
|
||||||
Text="截图"
|
Text="截图"
|
||||||
Visibility="Collapsed"/>
|
Visibility="Collapsed" />
|
||||||
<FlipView
|
<FlipView
|
||||||
x:Name="flipview"
|
x:Name="flipview"
|
||||||
MaxWidth="600"
|
MaxWidth="600"
|
||||||
|
@ -73,8 +66,7 @@
|
||||||
Visibility="Collapsed">
|
Visibility="Collapsed">
|
||||||
<FlipView.ItemTemplate>
|
<FlipView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="x:String">
|
<DataTemplate x:DataType="x:String">
|
||||||
<Image Source="{x:Bind Mode=OneTime}"
|
<Image Source="{x:Bind Mode=OneTime}" Stretch="Uniform" />
|
||||||
Stretch="Uniform"/>
|
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</FlipView.ItemTemplate>
|
</FlipView.ItemTemplate>
|
||||||
</FlipView>
|
</FlipView>
|
||||||
|
@ -91,19 +83,19 @@
|
||||||
Name="ReportButton"
|
Name="ReportButton"
|
||||||
Click="AppBarButton_Click"
|
Click="AppBarButton_Click"
|
||||||
Icon="ReportHacked"
|
Icon="ReportHacked"
|
||||||
Label="举报"/>
|
Label="举报" />
|
||||||
<AppBarSeparator/>
|
<AppBarSeparator />
|
||||||
<AppBarButton
|
<AppBarButton
|
||||||
Name="LikeButton"
|
Name="LikeButton"
|
||||||
Click="AppBarButton_Click"
|
Click="AppBarButton_Click"
|
||||||
Icon="Like"
|
Icon="Like"
|
||||||
Label="支持"/>
|
Label="支持" />
|
||||||
<AppBarSeparator/>
|
<AppBarSeparator />
|
||||||
<AppBarButton
|
<AppBarButton
|
||||||
Name="DownLoadButton"
|
Name="DownLoadButton"
|
||||||
Click="AppBarButton_Click"
|
Click="AppBarButton_Click"
|
||||||
Icon="Download"
|
Icon="Download"
|
||||||
Label="下载"/>
|
Label="下载" />
|
||||||
</CommandBar.PrimaryCommands>
|
</CommandBar.PrimaryCommands>
|
||||||
</CommandBar>
|
</CommandBar>
|
||||||
<TeachingTip
|
<TeachingTip
|
||||||
|
@ -115,18 +107,7 @@
|
||||||
IsLightDismissEnabled="True"
|
IsLightDismissEnabled="True"
|
||||||
PlacementMargin="20"
|
PlacementMargin="20"
|
||||||
PreferredPlacement="Auto"
|
PreferredPlacement="Auto"
|
||||||
Subtitle="消息"/>
|
Subtitle="消息" />
|
||||||
|
|
||||||
<ContentDialog
|
|
||||||
x:Name="DownloadDialog"
|
|
||||||
Title="下载中"
|
|
||||||
SecondaryButtonText="取消">
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Name="DownloadDialogText"
|
|
||||||
Text="下载完成后会自动导入到你配置的模组路径,请勿取消"/>
|
|
||||||
<ProgressBar Margin="0,6,0,0"
|
|
||||||
IsIndeterminate="True"/>
|
|
||||||
</StackPanel>
|
|
||||||
</ContentDialog>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</windowex:WindowEx>
|
</windowex:WindowEx>
|
||||||
|
|
|
@ -114,6 +114,13 @@ public sealed partial class ModuleInfoWin : WindowEx
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "DownLoadButton":
|
case "DownLoadButton":
|
||||||
|
DownMod();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void DownMod()
|
||||||
|
{
|
||||||
var iniHelper = new IniHelper();
|
var iniHelper = new IniHelper();
|
||||||
iniHelper.Load(IniHelper.FILE.Config);
|
iniHelper.Load(IniHelper.FILE.Config);
|
||||||
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
var v = iniHelper.GetValue(IniHelper.CODE.Rust, IniHelper.KEY.ModFileUrl);
|
||||||
|
@ -131,6 +138,22 @@ public sealed partial class ModuleInfoWin : WindowEx
|
||||||
return;
|
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();
|
var cancellationTokenSource = new CancellationTokenSource();
|
||||||
gj.sc("下载此模组:" + Mod.Link);
|
gj.sc("下载此模组:" + Mod.Link);
|
||||||
var downloader = new FileDownloader();
|
var downloader = new FileDownloader();
|
||||||
|
@ -145,7 +168,13 @@ public sealed partial class ModuleInfoWin : WindowEx
|
||||||
};
|
};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var PathMod = Path.Combine(v, Mod.Name);
|
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"))
|
if (File.Exists(PathMod + ".rwmod"))
|
||||||
{
|
{
|
||||||
File.Delete(PathMod + ".rwmod");
|
File.Delete(PathMod + ".rwmod");
|
||||||
|
@ -153,12 +182,16 @@ public sealed partial class ModuleInfoWin : WindowEx
|
||||||
//下载链接 保存文件的本地路径
|
//下载链接 保存文件的本地路径
|
||||||
await downloader.DownloadFileAsync(Mod.Link, PathMod, (totalBytesRead, totalBytes) =>
|
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.";
|
//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.");
|
textBlock.Text = $"下载进度:{(totalBytes > 0 ? (double)totalBytesRead / totalBytes * 100 : 0):0.00}%";
|
||||||
}, cancellationTokenSource.Token);
|
}, cancellationTokenSource.Token);
|
||||||
Debug.WriteLine("文件下载完成");
|
Debug.WriteLine("文件下载完成");
|
||||||
|
|
||||||
File.Move(PathMod, PathMod + ".rwmod");
|
File.Move(PathMod, PathMod + ".rwmod");
|
||||||
|
textBlock.Text = "文件下载完成";
|
||||||
DownloadDialog.Closing -= DownloadDialog_Closing;
|
DownloadDialog.Closing -= DownloadDialog_Closing;
|
||||||
|
DownloadDialog.IsSecondaryButtonEnabled = false;
|
||||||
|
await Task.Delay(1500);
|
||||||
// 手动隐藏对话框
|
// 手动隐藏对话框
|
||||||
DownloadDialog.Hide();
|
DownloadDialog.Hide();
|
||||||
|
|
||||||
|
@ -172,10 +205,13 @@ public sealed partial class ModuleInfoWin : WindowEx
|
||||||
DownloadDialog.Closing -= DownloadDialog_Closing;
|
DownloadDialog.Closing -= DownloadDialog_Closing;
|
||||||
DownloadDialog.Hide();
|
DownloadDialog.Hide();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 底部提示确定按钮
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="args"></param>
|
||||||
private void Toast_ActionButtonClick(TeachingTip sender, object args)
|
private void Toast_ActionButtonClick(TeachingTip sender, object args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -96,10 +96,10 @@ class wl
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//if (IsDelete)
|
if (IsDelete)
|
||||||
//{
|
{
|
||||||
// File.Delete(savePath);
|
File.Delete(savePath);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user