This commit is contained in:
Lightczx
2023-05-13 22:37:11 +08:00
parent 7a63013dfd
commit 456d87003f
16 changed files with 89 additions and 84 deletions

View File

@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved. // Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license. // Licensed under the MIT license.
using Snap.Hutao.Web.Hoyolab;
using System.Net.Http; using System.Net.Http;
namespace Snap.Hutao.Core.DependencyInjection; namespace Snap.Hutao.Core.DependencyInjection;

View File

@@ -6,6 +6,7 @@ using Microsoft.Web.WebView2.Core;
using Microsoft.Win32; using Microsoft.Win32;
using Snap.Hutao.Core.Setting; using Snap.Hutao.Core.Setting;
using System.IO; using System.IO;
using System.Security.Principal;
using Windows.ApplicationModel; using Windows.ApplicationModel;
using Windows.Storage; using Windows.Storage;
@@ -24,6 +25,8 @@ internal sealed class HutaoOptions : IOptions<HutaoOptions>
private readonly bool isWebView2Supported; private readonly bool isWebView2Supported;
private readonly string webView2Version = SH.CoreWebView2HelperVersionUndetected; private readonly string webView2Version = SH.CoreWebView2HelperVersionUndetected;
private bool? isElevated;
/// <summary> /// <summary>
/// 构造一个新的胡桃选项 /// 构造一个新的胡桃选项
/// </summary> /// </summary>
@@ -54,16 +57,16 @@ internal sealed class HutaoOptions : IOptions<HutaoOptions>
/// </summary> /// </summary>
public string UserAgent { get; } public string UserAgent { get; }
/// <summary>
/// 数据文件夹路径
/// </summary>
public string DataFolder { get; }
/// <summary> /// <summary>
/// 安装位置 /// 安装位置
/// </summary> /// </summary>
public string InstalledLocation { get; } public string InstalledLocation { get; }
/// <summary>
/// 数据文件夹路径
/// </summary>
public string DataFolder { get; }
/// <summary> /// <summary>
/// 本地缓存 /// 本地缓存
/// </summary> /// </summary>
@@ -89,6 +92,11 @@ internal sealed class HutaoOptions : IOptions<HutaoOptions>
/// </summary> /// </summary>
public bool IsWebView2Supported { get => isWebView2Supported; } public bool IsWebView2Supported { get => isWebView2Supported; }
/// <summary>
/// 是否为提升的权限
/// </summary>
public bool IsElevated { get => isElevated ??= GetElevated(); }
/// <inheritdoc/> /// <inheritdoc/>
public HutaoOptions Value { get => this; } public HutaoOptions Value { get => this; }
@@ -121,6 +129,19 @@ internal sealed class HutaoOptions : IOptions<HutaoOptions>
return Convert.ToMd5HexString($"{userName}{machineGuid}"); return Convert.ToMd5HexString($"{userName}{machineGuid}");
} }
private static bool GetElevated()
{
#if DEBUG_AS_FAKE_ELEVATED
return true;
#else
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
{
WindowsPrincipal principal = new(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
#endif
}
private void DetectWebView2Environment(ref string webView2Version, ref bool isWebView2Supported) private void DetectWebView2Environment(ref string webView2Version, ref bool isWebView2Supported)
{ {
try try

View File

@@ -54,30 +54,13 @@ internal static class Activation
private static readonly WeakReference<MainWindow> MainWindowReference = new(default!); private static readonly WeakReference<MainWindow> MainWindowReference = new(default!);
private static readonly SemaphoreSlim ActivateSemaphore = new(1); private static readonly SemaphoreSlim ActivateSemaphore = new(1);
/// <summary>
/// 获取是否提升了权限
/// </summary>
/// <returns>是否提升了权限</returns>
public static bool GetElevated()
{
#if DEBUG_AS_FAKE_ELEVATED
return true;
#else
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
{
WindowsPrincipal principal = new(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
#endif
}
/// <summary> /// <summary>
/// 以管理员模式重启 /// 以管理员模式重启
/// </summary> /// </summary>
/// <returns>任务</returns> /// <returns>任务</returns>
public static async ValueTask RestartAsElevatedAsync() public static async ValueTask RestartAsElevatedAsync()
{ {
if (!GetElevated()) // if (!GetElevated())
{ {
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(); await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
Process.GetCurrentProcess().Kill(); Process.GetCurrentProcess().Kill();

View File

@@ -2,6 +2,7 @@
// Licensed under the MIT license. // Licensed under the MIT license.
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Snap.Hutao.Core;
using Snap.Hutao.Core.Database; using Snap.Hutao.Core.Database;
using Snap.Hutao.Core.ExceptionService; using Snap.Hutao.Core.ExceptionService;
using Snap.Hutao.Core.IO.Ini; using Snap.Hutao.Core.IO.Ini;
@@ -33,6 +34,7 @@ internal sealed partial class GameService : IGameService
private readonly PackageConverter packageConverter; private readonly PackageConverter packageConverter;
private readonly IServiceProvider serviceProvider; private readonly IServiceProvider serviceProvider;
private readonly LaunchOptions launchOptions; private readonly LaunchOptions launchOptions;
private readonly HutaoOptions hutaoOptions;
private readonly ITaskContext taskContext; private readonly ITaskContext taskContext;
private readonly IMemoryCache memoryCache; private readonly IMemoryCache memoryCache;
private readonly AppOptions appOptions; private readonly AppOptions appOptions;
@@ -289,7 +291,7 @@ internal sealed partial class GameService : IGameService
game.Start(); game.Start();
bool isAdvancedOptionsAllowed = Activation.GetElevated() && appOptions.IsAdvancedLaunchOptionsEnabled; bool isAdvancedOptionsAllowed = hutaoOptions.IsElevated && appOptions.IsAdvancedLaunchOptionsEnabled;
if (isAdvancedOptionsAllowed && launchOptions.MultipleInstances && !isfirstInstance) if (isAdvancedOptionsAllowed && launchOptions.MultipleInstances && !isfirstInstance)
{ {
ProcessInterop.DisableProtection(game, gamePath); ProcessInterop.DisableProtection(game, gamePath);

View File

@@ -508,6 +508,12 @@
<Button.Flyout> <Button.Flyout>
<Flyout Placement="Left"> <Flyout Placement="Left">
<StackPanel MaxWidth="320"> <StackPanel MaxWidth="320">
<StackPanel.Resources>
<Thickness x:Key="SettingsCardPadding">16</Thickness>
<x:Double x:Key="SettingsCardWrapThreshold">0</x:Double>
<x:Double x:Key="SettingsCardWrapNoIconThreshold">0</x:Double>
<x:Double x:Key="SettingsCardMinHeight">0</x:Double>
</StackPanel.Resources>
<shct:DescriptionTextBlock Description="{Binding Description}"> <shct:DescriptionTextBlock Description="{Binding Description}">
<shct:DescriptionTextBlock.Resources> <shct:DescriptionTextBlock.Resources>
<Style BasedOn="{StaticResource BodyTextBlockStyle}" TargetType="TextBlock"> <Style BasedOn="{StaticResource BodyTextBlockStyle}" TargetType="TextBlock">
@@ -522,7 +528,7 @@
Margin="0,2,0,0" Margin="0,2,0,0"
Padding="12,0" Padding="12,0"
Header="{Binding Description}"> Header="{Binding Description}">
<TextBlock Text="{Binding Parameter}"/> <TextBlock Margin="0,8" Text="{Binding Parameter}"/>
</clw:SettingsCard> </clw:SettingsCard>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>

View File

@@ -63,7 +63,7 @@
Description="{shcm:ResourceString Name=ViewPageLaunchGameSwitchSchemeDescription}" Description="{shcm:ResourceString Name=ViewPageLaunchGameSwitchSchemeDescription}"
Header="{shcm:ResourceString Name=ViewPageLaunchGameSwitchSchemeHeader}" Header="{shcm:ResourceString Name=ViewPageLaunchGameSwitchSchemeHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xE8AB;}" HeaderIcon="{shcm:FontIcon Glyph=&#xE8AB;}"
IsEnabled="{Binding IsElevated}"> IsEnabled="{Binding HutaoOptions.IsElevated}">
<ComboBox <ComboBox
DisplayMemberPath="DisplayName" DisplayMemberPath="DisplayName"
ItemsSource="{Binding KnownSchemes}" ItemsSource="{Binding KnownSchemes}"
@@ -183,13 +183,19 @@
Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenWidthDescription}" Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenWidthDescription}"
Header="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenWidthHeader}" Header="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenWidthHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xE76F;}"> HeaderIcon="{shcm:FontIcon Glyph=&#xE76F;}">
<NumberBox Width="156" Value="{Binding Options.ScreenWidth, Mode=TwoWay}"/> <NumberBox
Width="156"
Padding="10,6,0,0"
Value="{Binding Options.ScreenWidth, Mode=TwoWay}"/>
</clw:SettingsCard> </clw:SettingsCard>
<clw:SettingsCard <clw:SettingsCard
Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenHeightDescription}" Description="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenHeightDescription}"
Header="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenHeightHeader}" Header="{shcm:ResourceString Name=ViewPageLaunchGameAppearanceScreenHeightHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xE784;}"> HeaderIcon="{shcm:FontIcon Glyph=&#xE784;}">
<NumberBox Width="156" Value="{Binding Options.ScreenHeight, Mode=TwoWay}"/> <NumberBox
Width="156"
Padding="10,6,0,0"
Value="{Binding Options.ScreenHeight, Mode=TwoWay}"/>
</clw:SettingsCard> </clw:SettingsCard>
<clw:SettingsCard <clw:SettingsCard
@@ -208,31 +214,29 @@
<clw:SettingsCard <clw:SettingsCard
Description="{shcm:ResourceString Name=ViewPageLaunchGameMultipleInstancesDescription}" Description="{shcm:ResourceString Name=ViewPageLaunchGameMultipleInstancesDescription}"
Header="{shcm:ResourceString Name=ViewPageLaunchGameMultipleInstancesHeader}" Header="{shcm:ResourceString Name=ViewPageLaunchGameMultipleInstancesHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xE7C4;}"> HeaderIcon="{shcm:FontIcon Glyph=&#xE7C4;}"
IsEnabled="{Binding HutaoOptions.IsElevated}">
<ToggleSwitch Width="120" IsOn="{Binding Options.MultipleInstances, Mode=TwoWay}"/> <ToggleSwitch Width="120" IsOn="{Binding Options.MultipleInstances, Mode=TwoWay}"/>
</clw:SettingsCard> </clw:SettingsCard>
<clw:SettingsCard <clw:SettingsCard
Description="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsDescription}" Description="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsDescription}"
Header="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsHeader}" Header="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xE785;}"> HeaderIcon="{shcm:FontIcon Glyph=&#xE785;}"
<ToggleSwitch IsEnabled="{Binding HutaoOptions.IsElevated}">
Width="120" <StackPanel Orientation="Horizontal">
IsOn="{Binding Options.UnlockFps, Mode=TwoWay}" <NumberBox
OffContent="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsOff}" MinWidth="156"
OnContent="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsOn}"/> Padding="10,8,0,0"
</clw:SettingsCard> Maximum="720"
<clw:SettingsCard Header="{shcm:ResourceString Name=ViewPageLaunchGameSetFpsHeader}"> Minimum="60"
<clw:SettingsCard.Description> SpinButtonPlacementMode="Inline"
<StackPanel> Value="{Binding Options.TargetFps, Mode=TwoWay}"/>
<TextBlock Text="{shcm:ResourceString Name=ViewPageLaunchGameSetFpsDescription}"/> <ToggleSwitch
<TextBlock Text="{Binding Options.TargetFps}"/> Width="120"
</StackPanel> IsOn="{Binding Options.UnlockFps, Mode=TwoWay}"
</clw:SettingsCard.Description> OffContent="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsOff}"
<Slider OnContent="{shcm:ResourceString Name=ViewPageLaunchGameUnlockFpsOn}"/>
Width="400" </StackPanel>
Maximum="360"
Minimum="60"
Value="{Binding Options.TargetFps, Mode=TwoWay}"/>
</clw:SettingsCard> </clw:SettingsCard>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

View File

@@ -211,7 +211,7 @@
Description="{shcm:ResourceString Name=ViewPageSettingIsAdvancedLaunchOptionsEnabledDescription}" Description="{shcm:ResourceString Name=ViewPageSettingIsAdvancedLaunchOptionsEnabledDescription}"
Header="{shcm:ResourceString Name=ViewPageSettingIsAdvancedLaunchOptionsEnabledHeader}" Header="{shcm:ResourceString Name=ViewPageSettingIsAdvancedLaunchOptionsEnabledHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xE730;}" HeaderIcon="{shcm:FontIcon Glyph=&#xE730;}"
IsEnabled="{Binding IsElevated}"> IsEnabled="{Binding HutaoOptions.IsElevated}">
<ToggleSwitch Width="120" IsOn="{Binding Options.IsAdvancedLaunchOptionsEnabled, Mode=TwoWay}"/> <ToggleSwitch Width="120" IsOn="{Binding Options.IsAdvancedLaunchOptionsEnabled, Mode=TwoWay}"/>
</clw:SettingsCard> </clw:SettingsCard>
<InfoBar <InfoBar

View File

@@ -3,6 +3,7 @@
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Snap.Hutao.Control.Extension; using Snap.Hutao.Control.Extension;
using Snap.Hutao.Core;
using Snap.Hutao.Core.ExceptionService; using Snap.Hutao.Core.ExceptionService;
using Snap.Hutao.Core.LifeCycle; using Snap.Hutao.Core.LifeCycle;
using Snap.Hutao.Model.Entity; using Snap.Hutao.Model.Entity;
@@ -34,6 +35,7 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel
private readonly IServiceProvider serviceProvider; private readonly IServiceProvider serviceProvider;
private readonly LaunchOptions launchOptions; private readonly LaunchOptions launchOptions;
private readonly HutaoOptions hutaoOptions;
private readonly ITaskContext taskContext; private readonly ITaskContext taskContext;
private readonly IGameService gameService; private readonly IGameService gameService;
private readonly IMemoryCache memoryCache; private readonly IMemoryCache memoryCache;
@@ -81,6 +83,11 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel
/// </summary> /// </summary>
public LaunchOptions Options { get => launchOptions; } public LaunchOptions Options { get => launchOptions; }
/// <summary>
/// 胡桃选项
/// </summary>
public HutaoOptions HutaoOptions { get => hutaoOptions; }
/// <summary> /// <summary>
/// 应用选项 /// 应用选项
/// </summary> /// </summary>
@@ -91,12 +98,6 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel
/// </summary> /// </summary>
public GameResource? GameResource { get => gameResource; set => SetProperty(ref gameResource, value); } public GameResource? GameResource { get => gameResource; set => SetProperty(ref gameResource, value); }
/// <summary>
/// 是否提权
/// </summary>
[SuppressMessage("", "CA1822")]
public bool IsElevated { get => Activation.GetElevated(); }
/// <inheritdoc/> /// <inheritdoc/>
protected override async Task OpenUIAsync() protected override async Task OpenUIAsync()
{ {

View File

@@ -100,15 +100,6 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
/// </summary> /// </summary>
public ExperimentalFeaturesViewModel Experimental { get => experimental; } public ExperimentalFeaturesViewModel Experimental { get => experimental; }
/// <summary>
/// 是否提权
/// </summary>
[SuppressMessage("", "CA1822")]
public bool IsElevated
{
get => Activation.GetElevated();
}
/// <inheritdoc/> /// <inheritdoc/>
protected override Task OpenUIAsync() protected override Task OpenUIAsync()
{ {

View File

@@ -18,24 +18,18 @@ internal sealed class SpiralAbyssView
/// <param name="idAvatarMap">Id角色映射</param> /// <param name="idAvatarMap">Id角色映射</param>
public SpiralAbyssView(Web.Hoyolab.Takumi.GameRecord.SpiralAbyss.SpiralAbyss spiralAbyss, Dictionary<AvatarId, Model.Metadata.Avatar.Avatar> idAvatarMap) public SpiralAbyssView(Web.Hoyolab.Takumi.GameRecord.SpiralAbyss.SpiralAbyss spiralAbyss, Dictionary<AvatarId, Model.Metadata.Avatar.Avatar> idAvatarMap)
{ {
Schedule = string.Format(SH.ModelEntitySpiralAbyssScheduleFormat, spiralAbyss.ScheduleId);
TotalBattleTimes = spiralAbyss.TotalBattleTimes; TotalBattleTimes = spiralAbyss.TotalBattleTimes;
TotalStar = spiralAbyss.TotalStar; TotalStar = spiralAbyss.TotalStar;
MaxFloor = spiralAbyss.MaxFloor; MaxFloor = spiralAbyss.MaxFloor;
Reveals = spiralAbyss.RevealRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).ToList(); Reveals = spiralAbyss.RevealRank.SelectList(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap));
Defeat = spiralAbyss.DefeatRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault(); Defeat = spiralAbyss.DefeatRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault();
Damage = spiralAbyss.DamageRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault(); Damage = spiralAbyss.DamageRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault();
TakeDamage = spiralAbyss.TakeDamageRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault(); TakeDamage = spiralAbyss.TakeDamageRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault();
NormalSkill = spiralAbyss.NormalSkillRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault(); NormalSkill = spiralAbyss.NormalSkillRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault();
EnergySkill = spiralAbyss.EnergySkillRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault(); EnergySkill = spiralAbyss.EnergySkillRank.Select(r => new RankAvatar(r.Value, r.AvatarId, idAvatarMap)).SingleOrDefault();
Floors = spiralAbyss.Floors.Select(f => new FloorView(f, idAvatarMap)).ToList(); Floors = spiralAbyss.Floors.Select(f => new FloorView(f, idAvatarMap)).Reverse().ToList();
} }
/// <summary>
/// 期
/// </summary>
public string Schedule { get; }
/// <summary> /// <summary>
/// 战斗次数 /// 战斗次数
/// </summary> /// </summary>

View File

@@ -19,7 +19,7 @@ internal static class CoreWebView2Extension
/// <returns>链式调用的WebView2</returns> /// <returns>链式调用的WebView2</returns>
public static CoreWebView2 SetMobileUserAgent(this CoreWebView2 webView) public static CoreWebView2 SetMobileUserAgent(this CoreWebView2 webView)
{ {
webView.Settings.UserAgent = Core.HoyolabOptions.MobileUserAgent; webView.Settings.UserAgent = HoyolabOptions.MobileUserAgent;
return webView; return webView;
} }
@@ -30,7 +30,7 @@ internal static class CoreWebView2Extension
/// <returns>链式调用的WebView2</returns> /// <returns>链式调用的WebView2</returns>
public static CoreWebView2 SetMobileOverseaUserAgent(this CoreWebView2 webView) public static CoreWebView2 SetMobileOverseaUserAgent(this CoreWebView2 webView)
{ {
webView.Settings.UserAgent = Core.HoyolabOptions.MobileUserAgentOversea; webView.Settings.UserAgent = HoyolabOptions.MobileUserAgentOversea;
return webView; return webView;
} }

View File

@@ -88,8 +88,8 @@ internal class MiHoYoJSInterface
Data = new Dictionary<string, string>() Data = new Dictionary<string, string>()
{ {
{ "x-rpc-client_type", "5" }, { "x-rpc-client_type", "5" },
{ "x-rpc-device_id", Core.HoyolabOptions.DeviceId }, { "x-rpc-device_id", HoyolabOptions.DeviceId },
{ "x-rpc-app_version", Core.HoyolabOptions.XrpcVersion }, { "x-rpc-app_version", HoyolabOptions.XrpcVersion },
}, },
}; };
} }
@@ -121,7 +121,7 @@ internal class MiHoYoJSInterface
/// <returns>响应</returns> /// <returns>响应</returns>
public virtual JsResult<Dictionary<string, string>> GetDynamicSecrectV1(JsParam param) public virtual JsResult<Dictionary<string, string>> GetDynamicSecrectV1(JsParam param)
{ {
string salt = Core.HoyolabOptions.Salts[SaltType.LK2]; string salt = HoyolabOptions.Salts[SaltType.LK2];
long t = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); long t = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
string r = GetRandomString(); string r = GetRandomString();
string check = Core.Convert.ToMd5HexString($"salt={salt}&t={t}&r={r}").ToLowerInvariant(); string check = Core.Convert.ToMd5HexString($"salt={salt}&t={t}&r={r}").ToLowerInvariant();
@@ -152,7 +152,7 @@ internal class MiHoYoJSInterface
public virtual JsResult<Dictionary<string, string>> GetDynamicSecrectV2(JsParam<DynamicSecrect2Playload> param) public virtual JsResult<Dictionary<string, string>> GetDynamicSecrectV2(JsParam<DynamicSecrect2Playload> param)
{ {
// TODO: Salt X4 for hoyolab user // TODO: Salt X4 for hoyolab user
string salt = Core.HoyolabOptions.Salts[SaltType.X4]; string salt = HoyolabOptions.Salts[SaltType.X4];
long t = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); long t = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
int r = GetRandom(); int r = GetRandom();
string b = param.Payload.Body; string b = param.Payload.Body;

View File

@@ -3,6 +3,7 @@
using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Web.Bridge.Model; using Snap.Hutao.Web.Bridge.Model;
using Snap.Hutao.Web.Hoyolab;
namespace Snap.Hutao.Web.Bridge; namespace Snap.Hutao.Web.Bridge;
@@ -35,8 +36,8 @@ internal sealed class SignInJSInterfaceOversea : MiHoYoJSInterface
Data = new Dictionary<string, string>() Data = new Dictionary<string, string>()
{ {
{ "x-rpc-client_type", "2" }, { "x-rpc-client_type", "2" },
{ "x-rpc-device_id", Core.HoyolabOptions.DeviceId }, { "x-rpc-device_id", HoyolabOptions.DeviceId },
{ "x-rpc-app_version", Core.HoyolabOptions.XrpcVersionOversea }, { "x-rpc-app_version", HoyolabOptions.XrpcVersionOversea },
}, },
}; };
} }

View File

@@ -3,6 +3,7 @@
using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Web.Bridge.Model; using Snap.Hutao.Web.Bridge.Model;
using Snap.Hutao.Web.Hoyolab;
namespace Snap.Hutao.Web.Bridge; namespace Snap.Hutao.Web.Bridge;
@@ -26,8 +27,8 @@ internal sealed class SignInJsInterface : MiHoYoJSInterface
Data = new Dictionary<string, string>() Data = new Dictionary<string, string>()
{ {
{ "x-rpc-client_type", "2" }, { "x-rpc-client_type", "2" },
{ "x-rpc-device_id", Core.HoyolabOptions.DeviceId }, { "x-rpc-device_id", HoyolabOptions.DeviceId },
{ "x-rpc-app_version", Core.HoyolabOptions.XrpcVersion }, { "x-rpc-app_version", HoyolabOptions.XrpcVersion },
}, },
}; };
} }

View File

@@ -33,7 +33,7 @@ internal sealed class DynamicSecretHandler : DelegatingHandler
private static async Task ProcessRequestWithOptionsAsync(HttpRequestMessage request, DynamicSecretCreationOptions options, CancellationToken token) private static async Task ProcessRequestWithOptionsAsync(HttpRequestMessage request, DynamicSecretCreationOptions options, CancellationToken token)
{ {
string salt = Core.HoyolabOptions.Salts[options.SaltType]; string salt = HoyolabOptions.Salts[options.SaltType];
long t = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); long t = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

View File

@@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
using Snap.Hutao.Web.Hoyolab.DynamicSecret; using Snap.Hutao.Web.Hoyolab.DynamicSecret;
using System.Collections.Immutable; using System.Collections.Immutable;
namespace Snap.Hutao.Core; namespace Snap.Hutao.Web.Hoyolab;
/// <summary> /// <summary>
/// 米游社选项 /// 米游社选项