mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
typo
This commit is contained in:
@@ -34,7 +34,7 @@ public static partial class Program
|
||||
// by adding the using statement, we can dispose the injected services when we closing
|
||||
using (ServiceProvider serviceProvider = InitializeDependencyInjection())
|
||||
{
|
||||
InitializeCulture(serviceProvider.GetRequiredService<AppOptions>().CurrentCulture);
|
||||
InitializeCulture(serviceProvider);
|
||||
|
||||
// In a Desktop app this runs a message pump internally,
|
||||
// and does not return until the application shuts down.
|
||||
@@ -49,8 +49,13 @@ public static partial class Program
|
||||
_ = Ioc.Default.GetRequiredService<App>();
|
||||
}
|
||||
|
||||
private static void InitializeCulture(CultureInfo cultureInfo)
|
||||
private static void InitializeCulture(IServiceProvider serviceProvider)
|
||||
{
|
||||
AppOptions appOptions = serviceProvider.GetRequiredService<AppOptions>();
|
||||
appOptions.PreviousCulture = CultureInfo.CurrentCulture;
|
||||
|
||||
CultureInfo cultureInfo = appOptions.CurrentCulture;
|
||||
|
||||
CultureInfo.CurrentCulture = cultureInfo;
|
||||
CultureInfo.CurrentUICulture = cultureInfo;
|
||||
ApplicationLanguages.PrimaryLanguageOverride = cultureInfo.Name;
|
||||
|
||||
@@ -55,6 +55,12 @@ internal sealed class AppOptions : DbStoreOptions
|
||||
set => SetOption(ref backdropType, SettingEntry.SystemBackdropType, value, value => value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化前的语言
|
||||
/// 通过设置与获取此属性,就可以获取到与系统同步的语言
|
||||
/// </summary>
|
||||
public CultureInfo PreviousCulture { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 当前语言
|
||||
/// </summary>
|
||||
|
||||
@@ -17,12 +17,11 @@ internal sealed partial class SignInWebViewDialog : ContentDialog
|
||||
{
|
||||
private readonly IServiceScope scope;
|
||||
[SuppressMessage("", "IDE0052")]
|
||||
private MiHoYoJSInterface? signInJsInterface;
|
||||
private MiHoYoJSInterface? jsInterface;
|
||||
|
||||
/// <summary>
|
||||
/// 构造一个新的签到网页视图对话框
|
||||
/// </summary>
|
||||
/// <param name="window">窗口</param>
|
||||
public SignInWebViewDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -49,20 +48,20 @@ internal sealed partial class SignInWebViewDialog : ContentDialog
|
||||
if (user.Entity.IsOversea)
|
||||
{
|
||||
coreWebView2.SetCookie(user.CookieToken, user.LToken, null, true).SetMobileOverseaUserAgent();
|
||||
signInJsInterface = new SignInJSInterfaceOversea(coreWebView2, scope.ServiceProvider);
|
||||
jsInterface = new SignInJSInterfaceOversea(coreWebView2, scope.ServiceProvider);
|
||||
coreWebView2.Navigate("https://act.hoyolab.com/ys/event/signin-sea-v3/index.html?act_id=e202102251931481");
|
||||
}
|
||||
else
|
||||
{
|
||||
coreWebView2.SetCookie(user.CookieToken, user.LToken, null, false).SetMobileUserAgent();
|
||||
signInJsInterface = new SignInJsInterface(coreWebView2, scope.ServiceProvider);
|
||||
jsInterface = new SignInJsInterface(coreWebView2, scope.ServiceProvider);
|
||||
coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnContentDialogClosed(ContentDialog sender, ContentDialogClosedEventArgs args)
|
||||
{
|
||||
signInJsInterface = null;
|
||||
jsInterface = null;
|
||||
scope.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -49,17 +49,17 @@ internal static class CoreWebView2Extension
|
||||
|
||||
if (cookieToken != null)
|
||||
{
|
||||
cookieManager.AddMihoyoCookie("account_id", cookieToken, isOversea).AddMihoyoCookie("cookie_token", cookieToken, isOversea);
|
||||
cookieManager.AddMihoyoCookie(Cookie.ACCOUNT_ID, cookieToken, isOversea).AddMihoyoCookie(Cookie.COOKIE_TOKEN, cookieToken, isOversea);
|
||||
}
|
||||
|
||||
if (lToken != null)
|
||||
{
|
||||
cookieManager.AddMihoyoCookie("ltuid", lToken, isOversea).AddMihoyoCookie("ltoken", lToken, isOversea);
|
||||
cookieManager.AddMihoyoCookie(Cookie.LTUID, lToken, isOversea).AddMihoyoCookie(Cookie.LTOKEN, lToken, isOversea);
|
||||
}
|
||||
|
||||
if (sToken != null)
|
||||
{
|
||||
cookieManager.AddMihoyoCookie("stuid", sToken, isOversea).AddMihoyoCookie("stoken", sToken, isOversea);
|
||||
cookieManager.AddMihoyoCookie(Cookie.STUID, sToken, isOversea).AddMihoyoCookie(Cookie.STOKEN, sToken, isOversea);
|
||||
}
|
||||
|
||||
return webView;
|
||||
@@ -67,7 +67,8 @@ internal static class CoreWebView2Extension
|
||||
|
||||
private static CoreWebView2CookieManager AddMihoyoCookie(this CoreWebView2CookieManager manager, string name, Cookie cookie, bool isOversea = false)
|
||||
{
|
||||
manager.AddOrUpdateCookie(manager.CreateCookie(name, cookie[name], isOversea ? ".hoyolab.com" : ".mihoyo.com", "/"));
|
||||
string domain = isOversea ? ".hoyolab.com" : ".mihoyo.com";
|
||||
manager.AddOrUpdateCookie(manager.CreateCookie(name, cookie[name], domain, "/"));
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Snap.Hutao.Service;
|
||||
using Snap.Hutao.Service.User;
|
||||
using Snap.Hutao.ViewModel.User;
|
||||
using Snap.Hutao.Web.Bridge.Model;
|
||||
@@ -262,12 +263,13 @@ internal class MiHoYoJSInterface
|
||||
/// <returns>语言与时区</returns>
|
||||
public virtual JsResult<Dictionary<string, string>> GetCurrentLocale(JsParam<PushPagePayload> param)
|
||||
{
|
||||
string cultureName = CultureInfo.CurrentCulture.Name;
|
||||
AppOptions appOptions = serviceProvider.GetRequiredService<AppOptions>();
|
||||
|
||||
return new()
|
||||
{
|
||||
Data = new()
|
||||
{
|
||||
["language"] = cultureName.ToLowerInvariant(),
|
||||
["language"] = appOptions.PreviousCulture.Name.ToLowerInvariant(),
|
||||
["timeZone"] = "GMT+8",
|
||||
},
|
||||
};
|
||||
@@ -389,6 +391,7 @@ internal class MiHoYoJSInterface
|
||||
"getActionTicket" => await GetActionTicketAsync(param).ConfigureAwait(false),
|
||||
"getCookieInfo" => GetCookieInfo(param),
|
||||
"getCookieToken" => await GetCookieTokenAsync(param).ConfigureAwait(false),
|
||||
"getCurrentLocale" => GetCurrentLocale(param),
|
||||
"getDS" => GetDynamicSecrectV1(param),
|
||||
"getDS2" => GetDynamicSecrectV2(param),
|
||||
"getHTTPRequestHeaders" => GetHttpRequestHeader(param),
|
||||
@@ -398,7 +401,6 @@ internal class MiHoYoJSInterface
|
||||
"login" => null,
|
||||
"pushPage" => await PushPageAsync(param).ConfigureAwait(false),
|
||||
"showLoading" => null,
|
||||
"getCurrentLocale" => GetCurrentLocale(param),
|
||||
_ => LogUnhandledMessage("Unhandled Message Type: {method}", param.Method),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user