mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 14:08:16 +08:00
fix
This commit is contained in:
+9
-1
@@ -204,7 +204,7 @@
|
||||
Height="100">
|
||||
</controls:ProgressRing>
|
||||
|
||||
<WrapPanel HorizontalAlignment="Center" Margin="0 0 0 50">
|
||||
<WrapPanel HorizontalAlignment="Center" Margin="0 0 0 40">
|
||||
<Button Classes="plain"
|
||||
Margin="0 0 25 0"
|
||||
HorizontalContentAlignment="Center"
|
||||
@@ -218,6 +218,14 @@
|
||||
Command="{Binding ChooseChannel}"
|
||||
CommandParameter="{Binding CurrentSelectChannel}"/>
|
||||
</WrapPanel>
|
||||
<WrapPanel HorizontalAlignment="Center" Margin="20 0 0 20">
|
||||
<Button Classes="plain"
|
||||
Margin="0 0 25 0"
|
||||
HorizontalContentAlignment="Center"
|
||||
Content="{ReflectionBinding Path=Res.Login_ManualLogin,Mode=OneWay,Source={x:Static resx:R.Current}}"
|
||||
Command="{ReflectionBinding ManualLogin}"
|
||||
/>
|
||||
</WrapPanel>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@@ -2583,6 +2583,33 @@ namespace System.Application.UI.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 手动登录 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Login_ManualLogin {
|
||||
get {
|
||||
return ResourceManager.GetString("Login_ManualLogin", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 输入的内容不能为空。 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Login_ManualLoginEmpt {
|
||||
get {
|
||||
return ResourceManager.GetString("Login_ManualLoginEmpt", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 数据解密失败,请确定数据正确重试。 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Login_WebSocketOnMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("Login_WebSocketOnMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 登录 / 注册 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -2601,6 +2628,15 @@ namespace System.Application.UI.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 请粘贴网页复制的内容。 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string LoginInputManualLoginToken {
|
||||
get {
|
||||
return ResourceManager.GetString("LoginInputManualLoginToken", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 注销登录 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -1574,4 +1574,16 @@
|
||||
<data name="Settings_UI_SelectImage" xml:space="preserve">
|
||||
<value>选择图片</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="Login_ManualLogin" xml:space="preserve">
|
||||
<value>手动登录</value>
|
||||
</data>
|
||||
<data name="LoginInputManualLoginToken" xml:space="preserve">
|
||||
<value>请粘贴网页复制的内容。</value>
|
||||
</data>
|
||||
<data name="Login_ManualLoginEmpt" xml:space="preserve">
|
||||
<value>输入的内容不能为空。</value>
|
||||
</data>
|
||||
<data name="Login_WebSocketOnMessage" xml:space="preserve">
|
||||
<value>数据解密失败,请确定数据正确重试。</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -58,29 +58,41 @@ namespace System.Application.UI.ViewModels
|
||||
|
||||
void OnBindSuccessed() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当接收到 WebSocket Client 发送的消息时
|
||||
/// </summary>
|
||||
/// <param name="vm"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <returns></returns>
|
||||
static async Task OnMessage(this IViewModel vm, string msg,IWebSocketConnection socket)
|
||||
public static async Task OnMessage(this IViewModel vm, string msg, IWebSocketConnection? socket)
|
||||
{
|
||||
if (vm.TempAes == null) return;
|
||||
var byteArray = msg.Base64UrlDecodeToByteArray();
|
||||
try {
|
||||
byteArray = vm.TempAes.Decrypt(byteArray);
|
||||
}
|
||||
catch {
|
||||
if (socket == null)
|
||||
Toast.Show(AppResources.Login_WebSocketOnMessage);
|
||||
return;
|
||||
}
|
||||
var response = ApiResponse.Deserialize<LoginOrRegisterResponse>(byteArray);
|
||||
var webResponse = new FastLRBWebResponse();
|
||||
if (response.IsSuccess && response.Content == null)
|
||||
{
|
||||
webResponse.Msg = ApiResponse.GetMessage(ApiResponseCode.NoResponseContent);
|
||||
await socket.Send(JsonSerializer.Serialize(webResponse));
|
||||
if (socket != null)
|
||||
await socket.Send(JsonSerializer.Serialize(webResponse));
|
||||
else
|
||||
Toast.Show(webResponse.Msg);
|
||||
return;
|
||||
}
|
||||
var conn_helper = DI.Get<IApiConnectionPlatformHelper>();
|
||||
webResponse.State = response.IsSuccess;
|
||||
await socket.Send(JsonSerializer.Serialize(webResponse)); // 仅可在 close 之前传递消息
|
||||
if (socket != null)
|
||||
await socket.Send(JsonSerializer.Serialize(webResponse)); // 仅可在 close 之前传递消息
|
||||
else
|
||||
Toast.Show(webResponse.Msg);
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
if (vm.IsBind)
|
||||
@@ -166,7 +178,6 @@ namespace System.Application.UI.ViewModels
|
||||
IPEndPoint[] ipEndPoints = iproperties.GetActiveTcpListeners();
|
||||
return ipEndPoints.Any(x => x.Port == port);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始第三方快速登录、注册、绑定
|
||||
/// </summary>
|
||||
@@ -197,10 +208,11 @@ namespace System.Application.UI.ViewModels
|
||||
vm.WebSocketServer = new($"ws://{IPAddress.Loopback}:{port}");
|
||||
vm.WebSocketServer.AddTo(vm);
|
||||
vm.ServerWebSocketListenerPort = port;
|
||||
vm.WebSocketServer.Start(socket => {
|
||||
vm.WebSocketServer.Start(socket =>
|
||||
{
|
||||
socket.OnMessage = async message => await vm.OnMessage(message, socket);
|
||||
});
|
||||
}
|
||||
}
|
||||
var conn_helper = DI.Get<IApiConnectionPlatformHelper>();
|
||||
var apiBaseUrl = ICloudServiceClient.Instance.ApiBaseUrl;
|
||||
#if DEBUG
|
||||
|
||||
+21
-1
@@ -57,6 +57,7 @@ namespace System.Application.UI.ViewModels
|
||||
}
|
||||
#endif
|
||||
});
|
||||
ManualLogin = ReactiveCommand.CreateFromTask(ManualLoginAsync);
|
||||
SendSms = ReactiveCommand.CreateFromTask(SendSmsAsync);
|
||||
Submit = ReactiveCommand.CreateFromTask(SubmitAsync);
|
||||
OpenHyperlink = ReactiveCommand.Create<string>(OpenHyperlink_);
|
||||
@@ -78,6 +79,26 @@ namespace System.Application.UI.ViewModels
|
||||
};
|
||||
}
|
||||
|
||||
public ICommand ManualLogin { get; }
|
||||
async Task ManualLoginAsync()
|
||||
{
|
||||
await MainThread2.InvokeOnMainThreadAsync(async () =>
|
||||
{
|
||||
TextBoxWindowViewModel vm = new()
|
||||
{
|
||||
Title = AppResources.LoginInputManualLoginToken,
|
||||
InputType = TextBoxWindowViewModel.TextBoxInputType.TextBox
|
||||
};
|
||||
await TextBoxWindowViewModel.ShowDialogAsync(vm);
|
||||
if (string.IsNullOrWhiteSpace(vm.Value))
|
||||
{
|
||||
Toast.Show(AppResources.Login_ManualLoginEmpt);
|
||||
return;
|
||||
}
|
||||
else
|
||||
await this.OnMessage(vm.Value, null);
|
||||
});
|
||||
}
|
||||
private string? _CurrentSelectChannel;
|
||||
public string? CurrentSelectChannel
|
||||
{
|
||||
@@ -205,7 +226,6 @@ namespace System.Application.UI.ViewModels
|
||||
public Action? TbSmsCodeFocus { get; set; }
|
||||
|
||||
public CancellationTokenSource? CTS { get; set; }
|
||||
|
||||
public ICommand SendSms { get; }
|
||||
|
||||
async Task SendSmsAsync() => await this.SendSmsAsync(() => new()
|
||||
|
||||
Reference in New Issue
Block a user