mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-22 09:36:09 +08:00
fix Bind LRB
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace System
|
||||
namespace System
|
||||
{
|
||||
public static class DateTimeFormat
|
||||
{
|
||||
@@ -27,5 +27,7 @@
|
||||
public const string DateCN = "yyyy年MM月dd日";
|
||||
|
||||
public const string DateCN2 = "yyyy年M月d日";
|
||||
|
||||
public const string RFC1123 = "r";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
@@ -41,6 +42,23 @@ namespace System
|
||||
.ToString();
|
||||
}
|
||||
|
||||
public static string Action(this IUrlHelper helper, string action, QueryString values)
|
||||
{
|
||||
var url = helper.Action(action);
|
||||
if (values.HasValue)
|
||||
{
|
||||
var length = url.Length + values.Value!.Length;
|
||||
return new StringBuilder(length)
|
||||
.Append(url)
|
||||
.Append(values.Value)
|
||||
.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取远程客户端的 IP 主机地址
|
||||
/// </summary>
|
||||
|
||||
@@ -21,6 +21,10 @@ namespace System.Application.UI.ViewModels
|
||||
{
|
||||
public static class FastLRBHelper
|
||||
{
|
||||
#if DEBUG
|
||||
static readonly bool UseLoopbackTest = false;
|
||||
#endif
|
||||
|
||||
public interface IViewModel : IDisposableHolder
|
||||
{
|
||||
/// <summary>
|
||||
@@ -157,7 +161,7 @@ namespace System.Application.UI.ViewModels
|
||||
/// <param name="vm"></param>
|
||||
/// <param name="channel"></param>
|
||||
/// <returns></returns>
|
||||
public static void StartLRB(this IViewModel vm, FastLoginChannel channel)
|
||||
public static async Task StartLRBAsync(this IViewModel vm, FastLoginChannel channel)
|
||||
{
|
||||
#if __MOBILE__
|
||||
switch (channel)
|
||||
@@ -179,12 +183,10 @@ namespace System.Application.UI.ViewModels
|
||||
}
|
||||
vm.ServerWebSocket.Start();
|
||||
var conn_helper = DI.Get<IApiConnectionPlatformHelper>();
|
||||
var apiBaseUrl =
|
||||
//#if DEBUG
|
||||
// "https://127.0.0.1:28110";
|
||||
//#else
|
||||
ICloudServiceClient.Instance.ApiBaseUrl;
|
||||
//#endif
|
||||
var apiBaseUrl = ICloudServiceClient.Instance.ApiBaseUrl;
|
||||
#if DEBUG
|
||||
if (UseLoopbackTest) apiBaseUrl = "https://127.0.0.1:28110";
|
||||
#endif
|
||||
|
||||
vm.TempAes.RemoveTo(vm);
|
||||
vm.TempAes = AESUtils.Create();
|
||||
@@ -194,16 +196,18 @@ ICloudServiceClient.Instance.ApiBaseUrl;
|
||||
var csc = DI.Get<CloudServiceClientBase>();
|
||||
var padding = RSAUtils.DefaultPadding;
|
||||
var isBind = vm.IsBind;
|
||||
var auth = string.Empty;
|
||||
var access_token = string.Empty;
|
||||
var access_token_expires = string.Empty;
|
||||
if (isBind)
|
||||
{
|
||||
Func<Task<JWTEntity?>> getAuthTokenAsync = () => conn_helper.Auth.GetAuthTokenAsync().AsTask();
|
||||
var authToken = getAuthTokenAsync.RunSync();
|
||||
var authToken = await conn_helper.Auth.GetAuthTokenAsync();
|
||||
var authHeaderValue = conn_helper.GetAuthenticationHeaderValue(authToken);
|
||||
if (authHeaderValue != null)
|
||||
{
|
||||
var authHeaderValueStr = authHeaderValue.ToString();
|
||||
auth = vm.TempAes.Encrypt(authHeaderValueStr);
|
||||
access_token = vm.TempAes.Encrypt(authHeaderValueStr);
|
||||
var now = DateTime.UtcNow;
|
||||
access_token_expires = vm.TempAes.Encrypt(now.ToString(DateTimeFormat.RFC1123));
|
||||
}
|
||||
}
|
||||
var url = apiBaseUrl +
|
||||
@@ -214,7 +218,8 @@ ICloudServiceClient.Instance.ApiBaseUrl;
|
||||
$"sKeyPadding={padding.OaepHashAlgorithm}&" +
|
||||
$"version={csc.Settings.AppVersionStr}&" +
|
||||
$"isBind={isBind}&" +
|
||||
$"auth={auth}";
|
||||
$"access_token_expires={access_token_expires}&" +
|
||||
$"access_token={access_token}";
|
||||
BrowserOpen(url);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -37,13 +37,13 @@ namespace System.Application.UI.ViewModels
|
||||
#endif
|
||||
AppResources.LoginAndRegister;
|
||||
|
||||
ChooseChannel = ReactiveCommand.Create<string>(channel_ =>
|
||||
ChooseChannel = ReactiveCommand.CreateFromTask<string>(async channel_ =>
|
||||
{
|
||||
if (Enum.TryParse<FastLoginChannel>(channel_, out var channel))
|
||||
{
|
||||
CurrentSelectChannel = channel_;
|
||||
ChangeLoginState(3);
|
||||
this.StartLRB(channel);
|
||||
await this.StartLRBAsync(channel);
|
||||
}
|
||||
#if !__MOBILE__
|
||||
else
|
||||
|
||||
@@ -82,11 +82,11 @@ namespace System.Application.UI.ViewModels
|
||||
SubscribeFormItem(x => x.AreaSelectItem3, SubscribeAreaOnNext);
|
||||
SubscribeFormItem(x => x.AreaSelectItem4, SubscribeAreaOnNext);
|
||||
}
|
||||
OnBindFastLoginClick = ReactiveCommand.Create<string>(channel_ =>
|
||||
OnBindFastLoginClick = ReactiveCommand.CreateFromTask<string>(async channel_ =>
|
||||
{
|
||||
if (Enum.TryParse<FastLoginChannel>(channel_, out var channel))
|
||||
{
|
||||
this.StartLRB(channel);
|
||||
await this.StartLRB(channel);
|
||||
}
|
||||
});
|
||||
OnUnbundleFastLoginClick = ReactiveCommand.CreateFromTask<string>(async channel_ =>
|
||||
|
||||
Reference in New Issue
Block a user