Files
MRCC/launcher/PCL-CE/Plain Craft Launcher 2/Pages/PageLaunch/PageLoginMs.xaml.cs
T
xyou f70b061d1a
CI / Go Backend (push) Canceled after 0s
feat: 项目初始化 + 3D方块世界原型 + AI助搭系统
初始化 monorepo: Go后端(7微服务) + Unity客户端(9模块) + 启动器

HTML5原型: Three.js 3D体素世界, Perlin噪声地形, 原版材质, 22种方块

Minecraft创造模式背包: 双栏布局, 拖拽移动物品, 方向性元件引脚

AI助搭策划文档 + 客户端/服务端骨架 + Docker Compose + CI
2026-08-08 14:07:56 +08:00

92 lines
3.4 KiB
C#

using System.Security.Authentication;
using System.Windows;
using PCL.Core.App.Localization;
namespace PCL;
public partial class PageLoginMs
{
public PageLoginMs()
{
// Handles
InitializeComponent();
BtnBack.Click += BtnBack_Click;
BtnLogin.Click += BtnLogin_Click;
}
private void BtnBack_Click(object sender, EventArgs e)
{
ModBase.RunInUi(() => ModMain.frmLaunchLeft.RefreshPage(true));
}
private void BtnLogin_Click(object sender, EventArgs e)
{
BtnLogin.IsEnabled = false;
BtnBack.Visibility = Visibility.Collapsed;
BtnLogin.Text = Lang.Number(0d, "P0");
ModBase.RunInNewThread(() =>
{
try
{
ModProfile.selectedProfile = null;
ModLaunch.mcLoginMsLoader.Start(ModProfile.GetLoginData(ModLaunch.McLoginType.Ms), true);
while (ModLaunch.mcLoginMsLoader.State == ModBase.LoadState.Loading)
{
ModBase.RunInUi(() => BtnLogin.Text = Lang.Number(ModLaunch.mcLoginMsLoader.Progress, "P0"));
Thread.Sleep(50);
}
if (ModLaunch.mcLoginMsLoader.State == ModBase.LoadState.Finished)
ModBase.RunInUi(() => ModMain.frmLaunchLeft.RefreshPage(true));
else if (ModLaunch.mcLoginMsLoader.State == ModBase.LoadState.Aborted)
throw new ThreadInterruptedException();
else if (ModLaunch.mcLoginMsLoader.Error is null)
throw new Exception(Lang.Text("Launch.Account.Microsoft.Error.Unknown"));
else
throw new Exception(ModLaunch.mcLoginMsLoader.Error.Message, ModLaunch.mcLoginMsLoader.Error);
}
catch (ThreadInterruptedException ex)
{
HintService.Hint(Lang.Text("Launch.Account.LoginCancelled"));
}
catch (Exception ex)
{
if (ex.Message == "$$")
{
}
else if (ex.Message.StartsWith("$"))
{
HintService.Hint(
Lang.Text("Launch.Account.Microsoft.LoginFailed.WithDetail", ex.Message.TrimStart('$')),
HintType.Error);
}
else if (ex is AuthenticationException && ex.Message.ContainsF("SSL/TLS"))
{
ModBase.Log(
ex,
$"{Lang.Text("Launch.Account.Microsoft.LoginFailed.Message")}\r\n{ex.Message}",
ModBase.LogLevel.Msgbox,
userSummary: Lang.Text("Launch.Account.Microsoft.Error.OperationFailed"));
}
else
{
ModBase.Log(
ex,
Lang.Text("Launch.Account.Microsoft.LoginFailed.Title"),
ModBase.LogLevel.Msgbox,
userSummary: Lang.Text("Launch.Account.Microsoft.LoginFailed.Title"));
}
}
finally
{
ModBase.RunInUi(() =>
{
BtnLogin.IsEnabled = true;
BtnBack.Visibility = Visibility.Visible;
BtnLogin.Text = Lang.Text("Launch.Account.Login");
});
}
}, "Ms Login");
}
}