mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-26 03:59:34 +08:00
Steam 快速登录 80%
即将发布 2.0.0.8
This commit is contained in:
@@ -64,37 +64,37 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<!--<ItemGroup>
|
||||
<TrimmerRootAssembly Include="CefNet" />
|
||||
<TrimmerRootAssembly Include="CefNet.Avalonia" />
|
||||
<TrimmerRootAssembly Include="CefNet"/>
|
||||
<TrimmerRootAssembly Include="CefNet.Avalonia"/>
|
||||
</ItemGroup>-->
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Startup2.cs" />
|
||||
<Compile Include="..\Startup2.cs"/>
|
||||
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
|
||||
<Link>Properties\AssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ST.Client.Desktop.Avalonia\ST.Client.Desktop.Avalonia.csproj" />
|
||||
<ProjectReference Include="..\ST.Client.Desktop\ST.Client.Desktop.csproj" />
|
||||
<ProjectReference Include="..\Common.CoreLib\Common.CoreLib.csproj" />
|
||||
<ProjectReference Include="..\ST.Client.Desktop.Avalonia\ST.Client.Desktop.Avalonia.csproj"/>
|
||||
<ProjectReference Include="..\ST.Client.Desktop\ST.Client.Desktop.csproj"/>
|
||||
<ProjectReference Include="..\Common.CoreLib\Common.CoreLib.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) Or ('$(OS)' == 'Windows_NT' And !$(DefineConstants.Contains(`PUBLISH`))) ">
|
||||
<ProjectReference Include="..\ST.Client.Desktop.Windows\ST.Client.Desktop.Windows.csproj" />
|
||||
<ProjectReference Include="..\ST.Client.Desktop.Windows\ST.Client.Desktop.Windows.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!--<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) And $(DefineConstants.Contains(`PUBLISH`)) ">
|
||||
<PackageReference Include="System.Reactive" Version="5.0.0.1-exclude-winforms" />
|
||||
<PackageReference Include="System.Reactive" Version="5.0.0.1-exclude-winforms"/>
|
||||
</ItemGroup>-->
|
||||
|
||||
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`osx`)) Or ('$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' And !$(DefineConstants.Contains(`PUBLISH`))) ">
|
||||
<ProjectReference Include="..\ST.Client.Desktop.Mac\ST.Client.Desktop.Mac.csproj" />
|
||||
<ProjectReference Include="..\ST.Client.Desktop.Mac\ST.Client.Desktop.Mac.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`linux`)) Or ('$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' And !$(DefineConstants.Contains(`PUBLISH`))) ">
|
||||
<ProjectReference Include="..\ST.Client.Desktop.Linux\ST.Client.Desktop.Linux.csproj" />
|
||||
<ProjectReference Include="..\ST.Client.Desktop.Linux\ST.Client.Desktop.Linux.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!--<ItemGroup Condition=" '$(OS)' == 'Windows_NT' And $(RuntimeIdentifier.Contains(`osx`)) And $(DefineConstants.Contains(`PUBLISH`)) ">
|
||||
@@ -118,7 +118,7 @@
|
||||
<AvaloniaResource Include="**\*.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</AvaloniaResource>
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
<AvaloniaResource Include="Assets\**"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" $(RuntimeIdentifier.Contains(`win`)) Or ('$(OS)' == 'Windows_NT' And !$(DefineConstants.Contains(`PUBLISH`))) ">
|
||||
@@ -138,22 +138,22 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="Exists('$(MSBuildProjectDirectory)\..\..\aes-key.pfx')">
|
||||
<EmbeddedResource Include="..\..\aes-key.pfx" Link="Resources\3A613E8D" />
|
||||
<EmbeddedResource Include="..\..\aes-key.pfx" Link="Resources\3A613E8D"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\app-id-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\app-id-debug.pfx" Link="Resources\0093BF84" />
|
||||
<EmbeddedResource Include="..\..\app-id-debug.pfx" Link="Resources\0093BF84"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' And Exists('$(MSBuildProjectDirectory)\..\..\rsa-public-key-debug.pfx')">
|
||||
<EmbeddedResource Include="..\..\rsa-public-key-debug.pfx" Link="Resources\6D72ED26" />
|
||||
<EmbeddedResource Include="..\..\rsa-public-key-debug.pfx" Link="Resources\6D72ED26"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\app-id-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\app-id-release.pfx" Link="Resources\F1D827AB" />
|
||||
<EmbeddedResource Include="..\..\app-id-release.pfx" Link="Resources\F1D827AB"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release' And Exists('$(MSBuildProjectDirectory)\..\..\rsa-public-key-release.pfx')">
|
||||
<EmbeddedResource Include="..\..\rsa-public-key-release.pfx" Link="Resources\E88CA4F9" />
|
||||
<EmbeddedResource Include="..\..\rsa-public-key-release.pfx" Link="Resources\E88CA4F9"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -7,6 +7,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Cryptography;
|
||||
using static System.Application.Services.CloudService.Constants;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
@@ -64,6 +66,10 @@ namespace System.Application.UI.Views.Controls
|
||||
/// 拦截响应流的处理
|
||||
/// </summary>
|
||||
public Action<string, byte[]>? OnStreamResponseFilterResourceLoadComplete { get; set; }
|
||||
|
||||
public bool IsSecurity { get; set; }
|
||||
|
||||
public Aes? Aes { get; internal set; }
|
||||
}
|
||||
|
||||
public class FullscreenModeChangeEventArgs : RoutedEventArgs
|
||||
@@ -209,6 +215,15 @@ namespace System.Application.UI.Views.Controls
|
||||
if (request.Url.StartsWith(sc.ApiBaseUrl, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
request.SetHeaderByName(Headers.Request.AppVersion, sc.Settings.AppVersionStr, true);
|
||||
if (webView.IsSecurity)
|
||||
{
|
||||
webView.Aes?.Dispose();
|
||||
webView.Aes = AESUtils.Create();
|
||||
var skey_bytes = webView.Aes.ToParamsByteArray();
|
||||
var conn_helper = DI.Get<IApiConnectionPlatformHelper>();
|
||||
var skey_str = conn_helper.RSA.EncryptToString(skey_bytes);
|
||||
request.SetHeaderByName(Headers.Request.SecurityKey, skey_str, true);
|
||||
}
|
||||
}
|
||||
var returnValue = base.OnBeforeResourceLoad(browser, frame, request, callback);
|
||||
return returnValue;
|
||||
@@ -261,7 +276,20 @@ namespace System.Application.UI.Views.Controls
|
||||
{
|
||||
if (webView.StreamResponseFilterUrls != null && webView.StreamResponseFilterUrls.Contains(request.Url, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
var dataFilter = new StreamResponseFilter();
|
||||
var rspIsCiphertext = false;
|
||||
if (webView.IsSecurity)
|
||||
{
|
||||
var contentType = response.GetHeaderByName("Content-Type");
|
||||
if (!string.IsNullOrWhiteSpace(contentType) && MediaTypeHeaderValue.TryParse(contentType, out var contentType_))
|
||||
{
|
||||
var mime = contentType_.MediaType;
|
||||
if (mime == MediaTypeNames.Security)
|
||||
{
|
||||
rspIsCiphertext = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
var dataFilter = new StreamResponseFilter(webView, rspIsCiphertext);
|
||||
responseDictionary.Add(request.Identifier, dataFilter);
|
||||
return dataFilter;
|
||||
}
|
||||
@@ -273,8 +301,15 @@ namespace System.Application.UI.Views.Controls
|
||||
/// </summary>
|
||||
unsafe class StreamResponseFilter : CefResponseFilter
|
||||
{
|
||||
readonly WebView3 webView;
|
||||
readonly bool rspIsCiphertext;
|
||||
MemoryStream? memoryStream;
|
||||
|
||||
public StreamResponseFilter(WebView3 webView, bool rspIsCiphertext)
|
||||
{
|
||||
this.webView = webView;
|
||||
}
|
||||
|
||||
protected override bool InitFilter()
|
||||
{
|
||||
memoryStream = new();
|
||||
@@ -339,9 +374,25 @@ namespace System.Application.UI.Views.Controls
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
byte[]? data;
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get { return memoryStream!.ToArray(); }
|
||||
get
|
||||
{
|
||||
if (data == null) data = GetData();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] GetData()
|
||||
{
|
||||
var value = memoryStream!.ToArray();
|
||||
if (rspIsCiphertext && webView.Aes != null)
|
||||
{
|
||||
value = webView.Aes.Decrypt(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
</Button>
|
||||
<Button Background="Transparent" Cursor="Hand"
|
||||
Command="{Binding ScriptStoreCommand}"
|
||||
ToolTip.Tip="{ReflectionBinding Path=Res.Script_Shop,Mode=OneWay,Source={x:Static resx:R.Current}}">
|
||||
ToolTip.Tip="{ReflectionBinding Path=Res.ScriptStore,Mode=OneWay,Source={x:Static resx:R.Current}}">
|
||||
<PathIcon Width="16" Data="{StaticResource JavaScriptDrawing}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
@@ -91,6 +91,7 @@ namespace System.Application.UI.Views.Windows
|
||||
base.OnDataContextChanged(e);
|
||||
if (DataContext is WebView3WindowViewModel vm)
|
||||
{
|
||||
vm.Close = Close;
|
||||
if (!string.IsNullOrWhiteSpace(vm.Title)) webView.DocumentTitleChanged -= WebView_DocumentTitleChanged;
|
||||
vm.WhenAnyValue(x => x.Url).WhereNotNull().Subscribe(x =>
|
||||
{
|
||||
@@ -118,6 +119,7 @@ namespace System.Application.UI.Views.Windows
|
||||
}).AddTo(vm);
|
||||
vm.WhenAnyValue(x => x.StreamResponseFilterUrls).Subscribe(x => webView.StreamResponseFilterUrls = x).AddTo(vm);
|
||||
vm.WhenAnyValue(x => x.FixedSinglePage).Subscribe(x => webView.FixedSinglePage = x).AddTo(vm);
|
||||
vm.WhenAnyValue(x => x.IsSecurity).Subscribe(x => webView.IsSecurity = x).AddTo(vm);
|
||||
webView.OnStreamResponseFilterResourceLoadComplete += vm.OnStreamResponseFilterResourceLoadComplete;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
@@ -16,20 +16,20 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DnsClient" Version="1.4.0" />
|
||||
<PackageReference Include="Gameloop.Vdf" Version="0.6.1" />
|
||||
<PackageReference Include="NLog" Version="4.7.9" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.2" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.3.1" />
|
||||
<PackageReference Include="StatefulModel.Standard" Version="0.1.0" />
|
||||
<PackageReference Include="DnsClient" Version="1.4.0"/>
|
||||
<PackageReference Include="Gameloop.Vdf" Version="0.6.1"/>
|
||||
<PackageReference Include="NLog" Version="4.7.9"/>
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.2"/>
|
||||
<PackageReference Include="SharpZipLib" Version="1.3.1"/>
|
||||
<PackageReference Include="StatefulModel.Standard" Version="0.1.0"/>
|
||||
<!--<PackageReference Include="Titanium.Web.Proxy" Version="3.1.1344" />-->
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7"/>
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.2"/>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ST.Client\ST.Client.csproj" />
|
||||
<ProjectReference Include="..\ST.Client\ST.Client.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -55,5 +55,4 @@
|
||||
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1872,15 +1872,6 @@ namespace System.Application.UI.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 脚本市场 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Script_Shop {
|
||||
get {
|
||||
return ResourceManager.GetString("Script_Shop", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 更新脚本 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -765,9 +765,6 @@
|
||||
<data name="Script_Refresh" xml:space="preserve">
|
||||
<value>Refresh the cache</value>
|
||||
</data>
|
||||
<data name="Script_Shop" xml:space="preserve">
|
||||
<value>Script market</value>
|
||||
</data>
|
||||
<data name="Script_Update" xml:space="preserve">
|
||||
<value>Update the script</value>
|
||||
</data>
|
||||
@@ -978,4 +975,4 @@
|
||||
<data name="ScriptShop_NoDelete_Basics" xml:space="preserve">
|
||||
<value>GM is the basic framework and cannot be deleted</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
||||
@@ -757,9 +757,6 @@
|
||||
<data name="Script_Refresh" xml:space="preserve">
|
||||
<value>キャッシュをフラッシュします</value>
|
||||
</data>
|
||||
<data name="Script_Shop" xml:space="preserve">
|
||||
<value>スクリプト市場</value>
|
||||
</data>
|
||||
<data name="Script_Update" xml:space="preserve">
|
||||
<value>スクリプトを更新します</value>
|
||||
</data>
|
||||
@@ -973,4 +970,4 @@
|
||||
<data name="ScriptShop_NoDelete_Basics" xml:space="preserve">
|
||||
<value>GM は基本フレームであり、削除は許可されていません</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
||||
@@ -756,9 +756,6 @@
|
||||
<data name="Script_Refresh" xml:space="preserve">
|
||||
<value>캐시를 새로 고칩니다</value>
|
||||
</data>
|
||||
<data name="Script_Shop" xml:space="preserve">
|
||||
<value>스크립트 마켓</value>
|
||||
</data>
|
||||
<data name="Script_Update" xml:space="preserve">
|
||||
<value>스크립트를 업데이트합니다</value>
|
||||
</data>
|
||||
@@ -972,4 +969,4 @@
|
||||
<data name="ScriptShop_NoDelete_Basics" xml:space="preserve">
|
||||
<value>GM 은 기본 프레임 인 데 삭제 가 안 돼 요</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
||||
@@ -744,9 +744,6 @@
|
||||
<data name="Script_ReplaceTips" xml:space="preserve">
|
||||
<value>已安装此脚本确定替换已安装的版本?</value>
|
||||
</data>
|
||||
<data name="Script_Shop" xml:space="preserve">
|
||||
<value>脚本市场</value>
|
||||
</data>
|
||||
<data name="Script_Update" xml:space="preserve">
|
||||
<value>更新脚本</value>
|
||||
</data>
|
||||
@@ -1041,4 +1038,4 @@
|
||||
<data name="Welcome" xml:space="preserve">
|
||||
<value>起始页</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
||||
@@ -756,9 +756,6 @@
|
||||
<data name="Script_Refresh" xml:space="preserve">
|
||||
<value>Обновите кэш</value>
|
||||
</data>
|
||||
<data name="Script_Shop" xml:space="preserve">
|
||||
<value>Рынок скриптов</value>
|
||||
</data>
|
||||
<data name="Script_Update" xml:space="preserve">
|
||||
<value>Обновите сценарий</value>
|
||||
</data>
|
||||
@@ -972,4 +969,4 @@
|
||||
<data name="ScriptShop_NoDelete_Basics" xml:space="preserve">
|
||||
<value>GM базовый шаблон не позволяет удалять</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
||||
@@ -762,9 +762,6 @@
|
||||
<data name="Script_Refresh" xml:space="preserve">
|
||||
<value>刷新緩存</value>
|
||||
</data>
|
||||
<data name="Script_Shop" xml:space="preserve">
|
||||
<value>腳本市場</value>
|
||||
</data>
|
||||
<data name="Script_Update" xml:space="preserve">
|
||||
<value>更新腳本</value>
|
||||
</data>
|
||||
@@ -978,4 +975,4 @@
|
||||
<data name="ScriptShop_NoDelete_Basics" xml:space="preserve">
|
||||
<value>GM 是基礎框架不允許删除</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
||||
@@ -16,7 +16,6 @@ using System.Linq;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using static Newtonsoft.Json.JsonConvert;
|
||||
|
||||
namespace System.Application.UI.ViewModels
|
||||
@@ -210,26 +209,10 @@ namespace System.Application.UI.ViewModels
|
||||
DebugString = @string.ToString();
|
||||
}
|
||||
|
||||
public /*async*/ void ShowDialogButton_Click()
|
||||
public async void ShowDialogButton_Click()
|
||||
{
|
||||
#if DEBUG
|
||||
var apiBaseUrl = ICloudServiceClient.Instance.ApiBaseUrl;
|
||||
var vm = new WebView3WindowViewModel
|
||||
{
|
||||
Url = apiBaseUrl + "/ExternalLogin",
|
||||
StreamResponseFilterUrls = new[]
|
||||
{
|
||||
apiBaseUrl + "/ExternalLoginCallback"
|
||||
},
|
||||
OnStreamResponseFilterResourceLoadComplete = (url, data) =>
|
||||
{
|
||||
|
||||
},
|
||||
FixedSinglePage = true,
|
||||
Title = AppResources.User_SteamFastLogin,
|
||||
TimeoutErrorMessage = AppResources.User_SteamFastLoginTimeoutErrorMessage,
|
||||
};
|
||||
IShowWindowService.Instance.Show(CustomWindow.WebView3, vm, resizeMode: ResizeModeCompat.NoResize);
|
||||
await LoginOrRegisterWindowViewModel.FastLoginOrRegisterAsync();
|
||||
#endif
|
||||
|
||||
//DI.Get<IDesktopPlatformService>().OpenDesktopIconsSettings();
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using ReactiveUI;
|
||||
using System.Application.Models;
|
||||
using System.Application.Services;
|
||||
using System.Application.Services.CloudService;
|
||||
using System.Application.UI.Resx;
|
||||
using System.Properties;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using static System.Application.Services.CloudService.Constants;
|
||||
|
||||
@@ -77,16 +79,64 @@ namespace System.Application.UI.ViewModels
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
await UserService.Current.RefreshUserAsync();
|
||||
var msg = AppResources.Success_.Format((response.Content?.IsLoginOrRegister ?? false) ? AppResources.User_Login : AppResources.User_Register);
|
||||
Toast.Show(msg);
|
||||
Close?.Invoke();
|
||||
await SuccessAsync(response.Content!, Close);
|
||||
return;
|
||||
}
|
||||
|
||||
IsLoading = false;
|
||||
}
|
||||
|
||||
static async Task SuccessAsync(LoginOrRegisterResponse rsp, Action? close)
|
||||
{
|
||||
await UserService.Current.RefreshUserAsync();
|
||||
var msg = AppResources.Success_.Format((rsp?.IsLoginOrRegister ?? false) ? AppResources.User_Login : AppResources.User_Register);
|
||||
Toast.Show(msg);
|
||||
close?.Invoke();
|
||||
}
|
||||
|
||||
internal static async Task FastLoginOrRegisterAsync()
|
||||
{
|
||||
var apiBaseUrl = ICloudServiceClient.Instance.ApiBaseUrl;
|
||||
var urlExternalLoginCallback = apiBaseUrl + "/ExternalLoginCallback";
|
||||
WebView3WindowViewModel? vm = null;
|
||||
vm = new WebView3WindowViewModel
|
||||
{
|
||||
Url = apiBaseUrl + "/ExternalLogin",
|
||||
StreamResponseFilterUrls = new[]
|
||||
{
|
||||
urlExternalLoginCallback,
|
||||
},
|
||||
OnStreamResponseFilterResourceLoadComplete = _OnStreamResponseFilterResourceLoadComplete,
|
||||
FixedSinglePage = true,
|
||||
Title = AppResources.User_SteamFastLogin,
|
||||
TimeoutErrorMessage = AppResources.User_SteamFastLoginTimeoutErrorMessage,
|
||||
IsSecurity = true,
|
||||
};
|
||||
async void _OnStreamResponseFilterResourceLoadComplete(string url, byte[] data)
|
||||
{
|
||||
if (url.StartsWith(urlExternalLoginCallback, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var response = ApiResponse.Deserialize<LoginOrRegisterResponse>(data);
|
||||
if (response.IsSuccess && response.Content == null)
|
||||
{
|
||||
response.Code = ApiResponseCode.NoResponseContent;
|
||||
}
|
||||
var conn_helper = DI.Get<IApiConnectionPlatformHelper>();
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
await conn_helper.OnLoginedAsync(null, response.Content!);
|
||||
await SuccessAsync(response.Content!, vm?.Close);
|
||||
}
|
||||
else
|
||||
{
|
||||
conn_helper.ShowResponseErrorMessage(response);
|
||||
vm?.Close?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
await IShowWindowService.Instance.Show(CustomWindow.WebView3, vm, resizeMode: ResizeModeCompat.NoResize);
|
||||
}
|
||||
|
||||
public Action? Close { private get; set; }
|
||||
|
||||
public Action? TbPhoneNumberFocus { get; set; }
|
||||
@@ -99,7 +149,6 @@ namespace System.Application.UI.ViewModels
|
||||
{
|
||||
if (this.TimeStart())
|
||||
{
|
||||
|
||||
var request = new SendSmsRequest
|
||||
{
|
||||
PhoneNumber = PhoneNumber,
|
||||
|
||||
@@ -41,5 +41,9 @@ namespace System.Application.UI.ViewModels
|
||||
/// 网页加载超时时提示文本
|
||||
/// </summary>
|
||||
public string? TimeoutErrorMessage { get; set; }
|
||||
|
||||
public bool IsSecurity { get; set; }
|
||||
|
||||
public Action? Close { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -39,9 +39,16 @@ namespace System.Application.Models
|
||||
return (IApiResponse<T>?)obj ?? ClientDeserializeFail<T>();
|
||||
}
|
||||
|
||||
public static IApiResponse<T> Deserialize<T>(byte[] buffer)
|
||||
{
|
||||
var type = GetDeserializeType<T>();
|
||||
var obj = MessagePackSerializer.Deserialize(type, buffer, options: Serializable.lz4Options);
|
||||
return (IApiResponse<T>?)obj ?? ClientDeserializeFail<T>();
|
||||
}
|
||||
|
||||
public static bool TryGetContent<T>(
|
||||
this IApiResponse<T> response,
|
||||
[NotNullWhen(true)] out T? content)
|
||||
this IApiResponse<T> response,
|
||||
[NotNullWhen(true)] out T? content)
|
||||
{
|
||||
content = response.Content;
|
||||
return response.IsSuccess && content != null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
|
||||
namespace System.Application.Models
|
||||
{
|
||||
@@ -127,6 +127,8 @@ namespace System.Application.Models
|
||||
/// </summary>
|
||||
AppObsolete,
|
||||
|
||||
RequiredWebViwe3,
|
||||
|
||||
/// <summary>
|
||||
/// 短信服务故障
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using System;
|
||||
using System.Application.Services;
|
||||
using System.Application.Services.CloudService;
|
||||
@@ -48,6 +48,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
;
|
||||
services.TryAddSingleton<T>();
|
||||
services.TryAddSingleton<CloudServiceClientBase>(s => s.GetRequiredService<T>());
|
||||
services.TryAddSingleton<IApiConnectionPlatformHelper>(s => s.GetRequiredService<T>());
|
||||
if (useMock && ThisAssembly.Debuggable)
|
||||
{
|
||||
#if DEBUG
|
||||
|
||||
@@ -267,11 +267,7 @@ namespace System.Application.Services.CloudService
|
||||
}
|
||||
|
||||
void ShowResponseErrorMessage(IApiResponse response, string? errorAppendText = null)
|
||||
{
|
||||
if (response.Code == ApiResponseCode.Canceled) return;
|
||||
var message = ApiResponse.GetMessage(response, errorAppendText);
|
||||
conn_helper.ShowResponseErrorMessage(message);
|
||||
}
|
||||
=> conn_helper.ShowResponseErrorMessage(response, errorAppendText);
|
||||
|
||||
async Task GlobalResponseIntercept(
|
||||
HttpMethod method,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Application.Columns;
|
||||
using System.Application.Columns;
|
||||
using System.Application.Models;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
@@ -33,6 +33,13 @@ namespace System.Application.Services.CloudService
|
||||
/// <param name="message"></param>
|
||||
void ShowResponseErrorMessage(string message);
|
||||
|
||||
void ShowResponseErrorMessage(IApiResponse response, string? errorAppendText = null)
|
||||
{
|
||||
if (response.Code == ApiResponseCode.Canceled) return;
|
||||
var message = ApiResponse.GetMessage(response, errorAppendText);
|
||||
ShowResponseErrorMessage(message);
|
||||
}
|
||||
|
||||
HttpClient CreateClient();
|
||||
|
||||
RSA RSA { get; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Application.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@@ -14,7 +14,7 @@ namespace System.Application.Services.CloudService
|
||||
/// <returns></returns>
|
||||
Task<IApiResponse<ScriptResponse>> Basics(string? errormsg = null);
|
||||
/// <summary>
|
||||
/// 脚本市场接口
|
||||
/// 脚本工坊接口
|
||||
/// </summary>
|
||||
/// <param name="name">脚本名称</param>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
|
||||
Reference in New Issue
Block a user