添加注册功能
This commit is contained in:
parent
acb2ed64d0
commit
c155980947
|
@ -1,15 +1,25 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Principal;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using RustTools.muqing;
|
using RustTools.muqing;
|
||||||
|
using RustTools.Views;
|
||||||
|
|
||||||
namespace RustTools.ApiFox;
|
namespace RustTools.ApiFox;
|
||||||
|
|
||||||
|
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
|
||||||
|
#pragma warning disable IDE1006 // 命名样式
|
||||||
public class user
|
public class user
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 登陆
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <param name="passWord"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static async Task<string> loginPc(string account, string passWord)
|
public static async Task<string> loginPc(string account, string passWord)
|
||||||
{
|
{
|
||||||
var pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
|
var pattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$";
|
||||||
|
@ -17,20 +27,57 @@ public class user
|
||||||
//gj.sc(account + " " + v); //这里不知道为什么会出现 True 而不是 true 导致识别邮箱失败
|
//gj.sc(account + " " + v); //这里不知道为什么会出现 True 而不是 true 导致识别邮箱失败
|
||||||
var task = await wl.postAsync("/php/user.php?action=loginPc", new string[][]
|
var task = await wl.postAsync("/php/user.php?action=loginPc", new string[][]
|
||||||
{
|
{
|
||||||
new string[]{ "account",account},
|
new[]{ "account",account},
|
||||||
new string[]{ "passWord", passWord },
|
new[]{ "passWord", passWord },
|
||||||
new string[]{ "isEmail", v.ToString().ToLower() }
|
new[]{ "isEmail", v.ToString().ToLower() }
|
||||||
});
|
});
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static async Task<string> SpaceInfo(string account)
|
public static async Task<string> SpaceInfo(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=getSpaceInfo", new string[][]
|
var task = await wl.postAsync("/php/user.php?action=getSpaceInfo", new string[][]
|
||||||
{
|
{
|
||||||
new string[]{ "account",account}
|
new[]{ "account",account}
|
||||||
});
|
});
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注册
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <param name="passWord"></param>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<string> register(string account,string userName,string passWord,string email)
|
||||||
|
{
|
||||||
|
var task = await wl.postAsync("/php/user.php?action=register", new string[][]
|
||||||
|
{
|
||||||
|
new []{ "account",account},
|
||||||
|
new []{ "userName", userName },
|
||||||
|
new []{ "passWord", passWord },
|
||||||
|
new []{ "email", email },
|
||||||
|
new []{ "appID",gj.GetUUID()}
|
||||||
|
});
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<string> enableAccount(string account, string key)
|
||||||
|
{
|
||||||
|
var task = await wl.postAsync("/php/user.php?action=enableAccount", new string[][]
|
||||||
|
{
|
||||||
|
new []{ "account",account},
|
||||||
|
new []{ "key", key }
|
||||||
|
});
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
|
||||||
## 开始使用
|
## 开始使用
|
||||||
如果你的电脑是win10+可以使用Visual Studio或Visual Studio Code 来运行此源码。
|
Windows10系统版本以上
|
||||||
|
Visual Studio Code
|
||||||
|
Visual Studio
|
||||||
|
JetBrains Rider
|
||||||
## 发布和安装
|
## 发布和安装
|
||||||
在VS 2022上面运行此源码后选择证书签名,打包后.msix文件点击运行,如果提示证书问题请双击.cer文件<br>
|
在Visual Studio上面运行此源码后选择证书签名,打包后.msix文件点击运行,如果提示证书问题请双击.cer文件<br>
|
||||||
点击安装证书,储存位置选择本地计算机 选择自定义储存为 受信任的根证书颁发机构 下一步保存即可
|
点击安装证书,储存位置选择本地计算机 选择自定义储存为 受信任的根证书颁发机构 下一步保存即可
|
||||||
|
|
||||||
## 注意事项
|
## 注意事项
|
||||||
|
@ -27,32 +30,16 @@ WinUI还是比较冷门的一个技术,代码和例子都不多 关于编译器
|
||||||
其实开发电脑版是作者对于铁锈的热爱开发的,请大家多多支持,开发不易。
|
其实开发电脑版是作者对于铁锈的热爱开发的,请大家多多支持,开发不易。
|
||||||
|
|
||||||
## 反馈
|
## 反馈
|
||||||
|
|
||||||
我们目前没有写反馈的接口和功能 你可以加群 点击链接加入群聊【铁锈助手】:https://qm.qq.com/q/dUfOK04pj2 在此反馈
|
我们目前没有写反馈的接口和功能 你可以加群 点击链接加入群聊【铁锈助手】:https://qm.qq.com/q/dUfOK04pj2 在此反馈
|
||||||
|
|
||||||
## 特别鸣谢 (参与项目开发)
|
## 特别鸣谢 (参与项目开发)
|
||||||
|
<a href="https://github.com/Cold-Mint/">
|
||||||
<div style=" display: inline-block;
|
<img src="https://q1.qlogo.cn/g?b=qq&nk=2923268971&s=100" style ="
|
||||||
text-align: center;
|
|
||||||
margin: 6px;
|
|
||||||
padding: 9px;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 10px;
|
|
||||||
width: 100px;
|
|
||||||
height: 100px;
|
|
||||||
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);">
|
|
||||||
<a href="https://github.com/Cold-Mint/">
|
|
||||||
<img src="http://q1.qlogo.cn/g?b=qq&nk=2923268971&s=100" style ="
|
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 66px;
|
width: 66px;
|
||||||
height: 66px;"/>
|
height: 66px;" alt="薄荷"/>
|
||||||
</a>
|
</a>
|
||||||
<p style="
|
|
||||||
margin-top: 5px;
|
|
||||||
font-size: 16px;
|
|
||||||
color: #333;">薄荷</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
## 开源协议
|
## 开源协议
|
||||||
虽然没什么用但还是要写一写
|
虽然没什么用但还是要写一写
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
<Button
|
<Button
|
||||||
Name="ZenrollButton"
|
Name="ZenrollButton"
|
||||||
Margin="0,0,0,0"
|
Margin="0,0,0,0"
|
||||||
Click="ZenrollButton_Click"
|
Click="enroll_Button_Click"
|
||||||
Content="注册"
|
Content="注册"
|
||||||
IsEnabled="False" />
|
IsEnabled="False" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace RustTools.Themes;
|
||||||
public sealed partial class LoginPage : UserControl
|
public sealed partial class LoginPage : UserControl
|
||||||
{
|
{
|
||||||
public delegate void LoginSucceededEventHandler(object sender, string e);
|
public delegate void LoginSucceededEventHandler(object sender, string e);
|
||||||
public event LoginSucceededEventHandler LoginSucceeded;
|
public event LoginSucceededEventHandler? LoginSucceeded;
|
||||||
public LoginPage()
|
public LoginPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -26,29 +26,12 @@ 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";
|
||||||
|
ZnameBox.Text = "muqing153";
|
||||||
|
ZpasswordBox.Password = "123456";
|
||||||
|
ZpasswordBox.Password= "123456";
|
||||||
|
ZemialBox.Text="123456@qq.com";
|
||||||
|
|
||||||
private void AgreementCheck_Checked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
loginButton.IsEnabled = loginButtonIsEnabled;
|
|
||||||
}
|
|
||||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
loginButton.IsEnabled = loginButtonIsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void ZAgreementCheck_Checked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ZenrollButton.IsEnabled = ZenrollButtonIsEnabled;
|
|
||||||
}
|
|
||||||
private void ZPasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ZenrollButton.IsEnabled = ZenrollButtonIsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AccountBox_TextChanged(object sender, TextChangedEventArgs e){
|
|
||||||
loginButton.IsEnabled = loginButtonIsEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -121,51 +104,153 @@ public sealed partial class LoginPage : UserControl
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private async void login_Click(object sender, RoutedEventArgs e)
|
private async void login_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var v = await user.loginPc(accountBox.Text, passwordBox.Password);
|
try
|
||||||
var message = JsonConvert.DeserializeObject<Message>(v);
|
|
||||||
if (message != null)
|
|
||||||
{
|
{
|
||||||
if (message.code == 0)
|
Toast.IsOpen = false;
|
||||||
|
var v = await user.loginPc(accountBox.Text, passwordBox.Password);
|
||||||
|
var message = JsonConvert.DeserializeObject<Message>(v);
|
||||||
|
if (message != null)
|
||||||
{
|
{
|
||||||
Toast.Title = "提示";
|
if (message.message.Equals("请先激活您的账户"))
|
||||||
Toast.Subtitle = message.message;
|
|
||||||
Toast.IsOpen = true;
|
|
||||||
if (message.data != null)
|
|
||||||
{
|
{
|
||||||
// 登录成功,触发事件
|
await enableAccountDialog(accountBox.Text);
|
||||||
var iniHelper = new IniHelper();
|
return;
|
||||||
iniHelper.Load(IniHelper.FILE.User);
|
}
|
||||||
iniHelper.SetValue(IniHelper.CODE.User, IniHelper.KEY.token, message.data.token);
|
if (message.code == 0)
|
||||||
iniHelper.SetValue(IniHelper.CODE.User, IniHelper.KEY.account, message.data.account);
|
{
|
||||||
iniHelper.Save();
|
Toast.Title = "提示";
|
||||||
LoginSucceeded?.Invoke(this, message.data.account);
|
Toast.Subtitle = message.message;
|
||||||
|
Toast.IsOpen = true;
|
||||||
|
await Task.Delay(500);
|
||||||
|
Toast.IsOpen = false;
|
||||||
|
if (message.data != null)
|
||||||
|
{
|
||||||
|
// 登录成功,触发事件
|
||||||
|
var iniHelper = new IniHelper();
|
||||||
|
iniHelper.Load(IniHelper.FILE.User);
|
||||||
|
iniHelper.SetValue(IniHelper.CODE.User, IniHelper.KEY.token, message.data.token);
|
||||||
|
iniHelper.SetValue(IniHelper.CODE.User, IniHelper.KEY.account, message.data.account);
|
||||||
|
iniHelper.Save();
|
||||||
|
LoginSucceeded?.Invoke(this, message.data.account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Toast.Title = "警告";
|
||||||
|
Toast.Subtitle = message.message;
|
||||||
|
Toast.IsOpen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
gj.sc(v);
|
||||||
{
|
}
|
||||||
Toast.Title = "警告";
|
catch (Exception ex)
|
||||||
Toast.Subtitle = message.message;
|
{
|
||||||
Toast.IsOpen = true;
|
gj.sc(ex);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
gj.sc(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void login()
|
/// <summary>
|
||||||
{
|
/// 注册
|
||||||
|
/// </summary>
|
||||||
}
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
public async void enroll_Button_Click(object sender, RoutedEventArgs e)
|
||||||
private void ZenrollButton_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
{
|
||||||
if (ZpasswordBox.Password != ZpasswordyesBox.Password)
|
if (ZpasswordBox.Password != ZpasswordyesBox.Password)
|
||||||
{
|
{
|
||||||
Toast.Title = "¾¯¸æ";
|
Toast.Title = "¾¯¸æ";
|
||||||
Toast.Subtitle = "ÃÜÂë²»Ò»ÖÂ";
|
Toast.Subtitle = "ÃÜÂë²»Ò»ÖÂ";
|
||||||
Toast.IsOpen = true;
|
Toast.IsOpen = true;
|
||||||
|
await Task.Delay(1000);
|
||||||
|
Toast.IsOpen = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var v = await user.register(ZaccountBox.Text, ZnameBox.Text, ZpasswordBox.Password, ZemialBox.Text);
|
||||||
|
gj.sc(v);
|
||||||
|
var message = JsonConvert.DeserializeObject<Message>(v);
|
||||||
|
if (message.code == 0)
|
||||||
|
{
|
||||||
|
Toast.Title = "提示";
|
||||||
|
Toast.Subtitle = message.message;
|
||||||
|
Toast.IsOpen = true;
|
||||||
|
CreateFadeTransitionStoryboard(enroll_view, login_view).Begin();
|
||||||
|
accountBox.Text=ZaccountBox.Text;
|
||||||
|
passwordBox.Password = ZpasswordBox.Password;
|
||||||
|
await enableAccountDialog(ZaccountBox.Text);
|
||||||
|
await Task.Delay(1000);
|
||||||
|
Toast.IsOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception ex)
|
||||||
|
{
|
||||||
|
Toast.Title = "警告";
|
||||||
|
Toast.Subtitle = ex.Message;
|
||||||
|
Toast.IsOpen = true;
|
||||||
|
await Task.Delay(1000);
|
||||||
|
Toast.IsOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 激活弹窗
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task enableAccountDialog(string account)
|
||||||
|
{
|
||||||
|
var textBox = new TextBox()
|
||||||
|
{
|
||||||
|
PlaceholderText = "激活码一般都在邮箱当中",
|
||||||
|
MaxLength=6,
|
||||||
|
};
|
||||||
|
var contentDialog = new ContentDialog()
|
||||||
|
{
|
||||||
|
XamlRoot = Content.XamlRoot,
|
||||||
|
Title ="激活码",
|
||||||
|
Content =textBox,
|
||||||
|
PrimaryButtonText = "确定",
|
||||||
|
PrimaryButtonStyle= Application.Current.Resources["AccentButtonStyle"] as Style,
|
||||||
|
CloseButtonText = "取消"
|
||||||
|
};
|
||||||
|
var result =await contentDialog.ShowAsync();
|
||||||
|
if (result == ContentDialogResult.Primary)
|
||||||
|
{
|
||||||
|
gj.sc(textBox.Text);
|
||||||
|
var v = await user.enableAccount(account, textBox.Text);
|
||||||
|
var message = JsonConvert.DeserializeObject<Message>(v);
|
||||||
|
if (message != null)
|
||||||
|
{
|
||||||
|
Toast.Title = "提示";
|
||||||
|
Toast.Subtitle = message.message;
|
||||||
|
Toast.IsOpen = true;
|
||||||
|
await Task.Delay(1000);
|
||||||
|
Toast.IsOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AgreementCheck_Checked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
loginButton.IsEnabled = loginButtonIsEnabled;
|
||||||
|
}
|
||||||
|
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
loginButton.IsEnabled = loginButtonIsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ZAgreementCheck_Checked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ZenrollButton.IsEnabled = ZenrollButtonIsEnabled;
|
||||||
|
}
|
||||||
|
private void ZPasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ZenrollButton.IsEnabled = ZenrollButtonIsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AccountBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
loginButton.IsEnabled = loginButtonIsEnabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,41 +41,5 @@ public class ModuleViewModel : ObservableRecipient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Button_Rwmod(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
var menuItem = sender as MenuFlyoutItem;
|
|
||||||
if (menuItem != null)
|
|
||||||
{
|
|
||||||
if (menuItem.DataContext is DataObject folderItem)
|
|
||||||
{
|
|
||||||
var filepath = Path.Combine(Path.GetDirectoryName(folderItem.Dri), folderItem.Name + ".rwmod");
|
|
||||||
if (File.Exists(filepath))
|
|
||||||
{
|
|
||||||
var show = await new ContentDialog()
|
|
||||||
{
|
|
||||||
XamlRoot = menuItem.XamlRoot,
|
|
||||||
Title = "警告",
|
|
||||||
Content = "已经存在必须覆盖",
|
|
||||||
PrimaryButtonText = "确定",
|
|
||||||
SecondaryButtonText = "取消"
|
|
||||||
}.ShowAsync();
|
|
||||||
if (show == ContentDialogResult.Primary)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 压缩zip
|
|
||||||
var v = wj.ZipExample(folderItem.Dri, folderItem.Name + ".rwmod");
|
|
||||||
if (v != string.Empty)
|
|
||||||
{
|
|
||||||
ListMod.Remove(new DataObject(new FileInfo(filepath)));
|
|
||||||
ListMod.Insert(0, new DataObject(new FileInfo(v)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
xmlns:local="using:RustTools.Views"
|
xmlns:local="using:RustTools.Views"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:themes="using:RustTools.Themes"
|
xmlns:themes="using:RustTools.Themes"
|
||||||
|
d:DataContext="{d:DesignInstance Type=local:ModulePage}"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Page.Resources>
|
<Page.Resources>
|
||||||
|
@ -55,7 +56,7 @@
|
||||||
<Button.Flyout>
|
<Button.Flyout>
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
<MenuFlyoutItem Text="打开" />
|
<MenuFlyoutItem Text="打开" />
|
||||||
<MenuFlyoutItem Click="ViewModel.Button_Rwmod" Text="打包" />
|
<MenuFlyoutItem Click="Button_Rwmod" Text="打包" />
|
||||||
<MenuFlyoutItem Text="发布" />
|
<MenuFlyoutItem Text="发布" />
|
||||||
<MenuFlyoutItem Click="Button_Delete" Text="删除" />
|
<MenuFlyoutItem Click="Button_Delete" Text="删除" />
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
|
|
|
@ -82,13 +82,12 @@ public sealed partial class ModulePage : Page
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
}
|
}
|
||||||
//private void ShowMenu(bool isTransient, GridViewItem dataTemplate)
|
|
||||||
//{
|
|
||||||
// FlyoutShowOptions myOption = new FlyoutShowOptions();
|
|
||||||
// myOption.ShowMode = isTransient ? FlyoutShowMode.Transient : FlyoutShowMode.Standard;
|
|
||||||
// CommandBarFlyout1.ShowAt(dataTemplate, myOption);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打开模组
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var button = sender as Button;
|
var button = sender as Button;
|
||||||
|
@ -104,6 +103,13 @@ public sealed partial class ModulePage : Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除模组和文件夹
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void Button_Delete(object sender, RoutedEventArgs e)
|
private void Button_Delete(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var menuItem = sender as Control;
|
var menuItem = sender as Control;
|
||||||
|
@ -128,6 +134,12 @@ public sealed partial class ModulePage : Page
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解压模组
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private async void Button_Click_RwmodItem(object sender, RoutedEventArgs e)
|
private async void Button_Click_RwmodItem(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ContentDialog dialog = new ContentDialog();
|
ContentDialog dialog = new ContentDialog();
|
||||||
|
@ -146,7 +158,7 @@ public sealed partial class ModulePage : Page
|
||||||
var container = VisualTreeHelper.GetParent(button) as FrameworkElement;
|
var container = VisualTreeHelper.GetParent(button) as FrameworkElement;
|
||||||
if (container != null && container.DataContext is DataObject dataItem)
|
if (container != null && container.DataContext is DataObject dataItem)
|
||||||
{
|
{
|
||||||
CheckBox checkbox = (dialog.Content as StackPanel)?.Children[1] as CheckBox;
|
var checkbox = (dialog.Content as StackPanel)?.Children[1] as CheckBox;
|
||||||
if (checkbox.IsChecked == true)
|
if (checkbox.IsChecked == true)
|
||||||
{
|
{
|
||||||
File.Delete(dataItem.Dri);
|
File.Delete(dataItem.Dri);
|
||||||
|
@ -183,13 +195,56 @@ public sealed partial class ModulePage : Page
|
||||||
{
|
{
|
||||||
Text = "解压模组到目录",
|
Text = "解压模组到目录",
|
||||||
};
|
};
|
||||||
|
|
||||||
var stackPanel = new StackPanel();
|
var stackPanel = new StackPanel();
|
||||||
stackPanel.Children.Add(text);
|
stackPanel.Children.Add(text);
|
||||||
stackPanel.Children.Add(checkbox);
|
stackPanel.Children.Add(checkbox);
|
||||||
return stackPanel;
|
return stackPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打包模组
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
public async void Button_Rwmod(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
var menuItem = sender as MenuFlyoutItem;
|
||||||
|
if (menuItem != null)
|
||||||
|
{
|
||||||
|
if (menuItem.DataContext is DataObject folderItem)
|
||||||
|
{
|
||||||
|
var filepath = Path.Combine(Path.GetDirectoryName(folderItem.Dri), folderItem.Name + ".rwmod");
|
||||||
|
if (File.Exists(filepath))
|
||||||
|
{
|
||||||
|
var show = await new ContentDialog()
|
||||||
|
{
|
||||||
|
XamlRoot = menuItem.XamlRoot,
|
||||||
|
Title = "警告",
|
||||||
|
Content = "已经存在必须覆盖",
|
||||||
|
PrimaryButtonText = "确定",
|
||||||
|
SecondaryButtonText = "取消"
|
||||||
|
}.ShowAsync();
|
||||||
|
if (show == ContentDialogResult.Primary)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 压缩zip
|
||||||
|
var v = wj.ZipExample(folderItem.Dri, folderItem.Name + ".rwmod");
|
||||||
|
if (v != string.Empty)
|
||||||
|
{
|
||||||
|
ViewModel.ListMod.Remove(new DataObject(new FileInfo(filepath)));
|
||||||
|
ViewModel.ListMod.Insert(0, new DataObject(new FileInfo(v)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public class MyItemTemplateSelector : DataTemplateSelector
|
public class MyItemTemplateSelector : DataTemplateSelector
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,27 +24,15 @@ public class gj
|
||||||
|
|
||||||
public static string GetUUID()
|
public static string GetUUID()
|
||||||
{
|
{
|
||||||
try
|
var newGuid = Guid.NewGuid();
|
||||||
{
|
return newGuid.ToString();
|
||||||
using var searcher = new ManagementObjectSearcher("select UUID from Win32_ComputerSystemProduct");
|
|
||||||
foreach (var obj in searcher.Get().Cast<ManagementObject>())
|
|
||||||
{
|
|
||||||
return obj["UUID"] != null ? (string)obj["UUID"] : "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"An error occurred while retrieving the UUID: {ex.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置window窗口适配器 主题颜色
|
/// 设置window窗口适配器 主题颜色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static async void SetBackTheme(WindowEx windowEx)
|
public static void SetBackTheme(WindowEx windowEx)
|
||||||
{
|
{
|
||||||
var iniHelper = new IniHelper();
|
var iniHelper = new IniHelper();
|
||||||
iniHelper.Load(IniHelper.FILE.Config);
|
iniHelper.Load(IniHelper.FILE.Config);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user