mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
ignore invalid launch schemes
This commit is contained in:
@@ -49,6 +49,13 @@ internal readonly struct ChannelOptions
|
||||
ConfigFilePath = configFilePath;
|
||||
}
|
||||
|
||||
public ChannelOptions(ChannelType channel, SubChannelType subChannel, bool isOversea)
|
||||
{
|
||||
Channel = channel;
|
||||
SubChannel = subChannel;
|
||||
IsOversea = isOversea;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件未找到
|
||||
/// </summary>
|
||||
@@ -65,4 +72,9 @@ internal readonly struct ChannelOptions
|
||||
{
|
||||
return $"[ChannelType:{Channel}] [SubChannel:{SubChannel}] [IsOversea: {IsOversea}]";
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(Channel, SubChannel, IsOversea);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Model.Intrinsic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace Snap.Hutao.Service.Game;
|
||||
|
||||
internal static class IgnoredInvalidChannelOptions
|
||||
{
|
||||
private static readonly ImmutableHashSet<ChannelOptions> InvalidOptions = new HashSet<ChannelOptions>()
|
||||
{
|
||||
new(ChannelType.Bili, SubChannelType.Official, true),
|
||||
}.ToImmutableHashSet();
|
||||
|
||||
public static bool Contains(in ChannelOptions options)
|
||||
{
|
||||
return InvalidOptions.Contains(options);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ internal partial class WebViewer : UserControl, IRecipient<UserChangedMessage>
|
||||
CoreWebView2Navigator navigator = new(coreWebView2);
|
||||
await navigator.NavigateAsync("about:blank").ConfigureAwait(true);
|
||||
|
||||
coreWebView2.SetCookie(user.CookieToken, user.LToken, user.SToken);
|
||||
coreWebView2.SetCookie(user.CookieToken, user.LToken);
|
||||
_ = userAndUid.User.IsOversea ? coreWebView2.SetMobileOverseaUserAgent() : coreWebView2.SetMobileUserAgent();
|
||||
jsInterface?.Detach();
|
||||
jsInterface = SourceProvider.CreateJsInterface(serviceProvider, coreWebView2, userAndUid);
|
||||
|
||||
@@ -34,12 +34,12 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel
|
||||
public const string DesiredUid = nameof(DesiredUid);
|
||||
|
||||
private readonly IContentDialogFactory contentDialogFactory;
|
||||
private readonly LaunchStatusOptions launchStatusOptions;
|
||||
private readonly INavigationService navigationService;
|
||||
private readonly IInfoBarService infoBarService;
|
||||
private readonly LaunchOptions launchOptions;
|
||||
private readonly LaunchStatusOptions launchStatusOptions;
|
||||
private readonly RuntimeOptions hutaoOptions;
|
||||
private readonly ResourceClient resourceClient;
|
||||
private readonly LaunchOptions launchOptions;
|
||||
private readonly RuntimeOptions hutaoOptions;
|
||||
private readonly IUserService userService;
|
||||
private readonly ITaskContext taskContext;
|
||||
private readonly IGameService gameService;
|
||||
@@ -125,8 +125,11 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// 后台收集
|
||||
throw new NotSupportedException($"不支持的 MultiChannel: {options}");
|
||||
if (!IgnoredInvalidChannelOptions.Contains(options))
|
||||
{
|
||||
// 后台收集
|
||||
throw new NotSupportedException($"不支持的 MultiChannel: {options}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -67,10 +67,9 @@ internal static class CoreWebView2Extension
|
||||
/// <param name="webView">webView2</param>
|
||||
/// <param name="cookieToken">CookieToken</param>
|
||||
/// <param name="lToken">LToken</param>
|
||||
/// <param name="sToken">SToken</param>
|
||||
/// <param name="isOversea">是否为国际服,用于改变 cookie domain</param>
|
||||
/// <returns>链式调用的WebView2</returns>
|
||||
public static CoreWebView2 SetCookie(this CoreWebView2 webView, Cookie? cookieToken = null, Cookie? lToken = null, Cookie? sToken = null, bool isOversea = false)
|
||||
public static CoreWebView2 SetCookie(this CoreWebView2 webView, Cookie? cookieToken = null, Cookie? lToken = null, bool isOversea = false)
|
||||
{
|
||||
CoreWebView2CookieManager cookieManager = webView.CookieManager;
|
||||
|
||||
@@ -88,14 +87,6 @@ internal static class CoreWebView2Extension
|
||||
.AddMihoyoCookie(Cookie.LTOKEN, lToken, isOversea);
|
||||
}
|
||||
|
||||
if (sToken is not null)
|
||||
{
|
||||
cookieManager
|
||||
.AddMihoyoCookie(Cookie.MID, sToken, isOversea)
|
||||
.AddMihoyoCookie(Cookie.STUID, sToken, isOversea)
|
||||
.AddMihoyoCookie(Cookie.STOKEN, sToken, isOversea);
|
||||
}
|
||||
|
||||
return webView;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user