mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix #368
This commit is contained in:
31
src/Snap.Hutao/Snap.Hutao/Core/Setting/StaticResource.cs
Normal file
31
src/Snap.Hutao/Snap.Hutao/Core/Setting/StaticResource.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Core.Setting;
|
||||
|
||||
/// <summary>
|
||||
/// 静态资源
|
||||
/// </summary>
|
||||
internal static class StaticResource
|
||||
{
|
||||
/// <summary>
|
||||
/// 提供的合约是否未完成
|
||||
/// </summary>
|
||||
/// <param name="contractKey">合约的键</param>
|
||||
/// <returns>合约是否未完成</returns>
|
||||
public static bool IsContractUnfulfilled(string contractKey)
|
||||
{
|
||||
return !LocalSetting.Get(contractKey, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否有任何静态资源合约尚未完成
|
||||
/// </summary>
|
||||
/// <returns>静态资源合约尚未完成</returns>
|
||||
public static bool IsAnyUnfulfilledContractPresent()
|
||||
{
|
||||
return !LocalSetting.Get(SettingKeys.StaticResourceV1Contract, false)
|
||||
|| (!LocalSetting.Get(SettingKeys.StaticResourceV2Contract, false))
|
||||
|| (!LocalSetting.Get(SettingKeys.StaticResourceV3Contract, false));
|
||||
}
|
||||
}
|
||||
@@ -33,11 +33,8 @@ public sealed partial class MainWindow : Window, IExtendedWindowSource, IRecipie
|
||||
|
||||
Ioc.Default.GetRequiredService<IMessenger>().Register(this);
|
||||
|
||||
// Query the StaticResourceV1Contract & StaticResourceV2Contract.
|
||||
// If not complete we should present the welcome view.
|
||||
ContentSwitchPresenter.Value =
|
||||
!LocalSetting.Get(SettingKeys.StaticResourceV1Contract, false)
|
||||
|| (!LocalSetting.Get(SettingKeys.StaticResourceV2Contract, false));
|
||||
ContentSwitchPresenter.Value = StaticResource.IsAnyUnfulfilledContractPresent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<Identity
|
||||
Name="7f0db578-026f-4e0b-a75b-d5d06bb0a74d"
|
||||
Publisher="CN=DGP Studio"
|
||||
Version="1.3.10.0" />
|
||||
Version="1.3.12.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>胡桃</DisplayName>
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Snap.Hutao.View.Dialog;
|
||||
/// <summary>
|
||||
/// 实时便笺验证对话框
|
||||
/// </summary>
|
||||
[SuppressMessage("", "CA1001")]
|
||||
public sealed partial class DailyNoteVerificationDialog : ContentDialog
|
||||
{
|
||||
private readonly IServiceScope scope;
|
||||
@@ -58,8 +59,12 @@ public sealed partial class DailyNoteVerificationDialog : ContentDialog
|
||||
|
||||
private void OnContentDialogClosed(ContentDialog sender, ContentDialogClosedEventArgs args)
|
||||
{
|
||||
dailyNoteJsInterface.ClosePageRequested -= OnClosePageRequested;
|
||||
dailyNoteJsInterface = null;
|
||||
if (dailyNoteJsInterface != null)
|
||||
{
|
||||
dailyNoteJsInterface!.ClosePageRequested -= OnClosePageRequested;
|
||||
dailyNoteJsInterface = null;
|
||||
}
|
||||
|
||||
scope.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -115,13 +115,9 @@ internal class AvatarPropertyViewModel : Abstraction.ViewModel
|
||||
|
||||
private Task OpenUIAsync()
|
||||
{
|
||||
if (userService.Current is User user)
|
||||
if (UserAndUid.TryFromUser(userService.Current, out UserAndUid? userAndUid))
|
||||
{
|
||||
if (user.SelectedUserGameRole is UserGameRole role)
|
||||
{
|
||||
UserAndUid userAndUid = new(user.Entity, role);
|
||||
return RefreshCoreAsync(userAndUid, RefreshOption.None, CancellationToken);
|
||||
}
|
||||
return RefreshCoreAsync(userAndUid, RefreshOption.None, CancellationToken);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -72,12 +72,12 @@ internal class SpiralAbyssRecordViewModel : Abstraction.ViewModel, IRecipient<Us
|
||||
{
|
||||
get => selectedEntry; set
|
||||
{
|
||||
if (SetProperty(ref selectedEntry, value))
|
||||
// We dont need to check the result here,
|
||||
// just refresh the view anyway.
|
||||
SetProperty(ref selectedEntry, value);
|
||||
if (value != null && idAvatarMap != null)
|
||||
{
|
||||
if (value != null && idAvatarMap != null)
|
||||
{
|
||||
SpiralAbyssView = new(value.SpiralAbyss, idAvatarMap);
|
||||
}
|
||||
SpiralAbyssView = new(value.SpiralAbyss, idAvatarMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ internal class WelcomeViewModel : ObservableObject
|
||||
{
|
||||
Dictionary<string, DownloadSummary> downloadSummaries = new();
|
||||
|
||||
if (!LocalSetting.Get(SettingKeys.StaticResourceV1Contract, false))
|
||||
if (StaticResource.IsContractUnfulfilled(SettingKeys.StaticResourceV1Contract))
|
||||
{
|
||||
downloadSummaries.TryAdd("Bg", new(serviceProvider, "基础图标", "Bg"));
|
||||
downloadSummaries.TryAdd("AvatarIcon", new(serviceProvider, "角色图标", "AvatarIcon"));
|
||||
@@ -102,7 +102,7 @@ internal class WelcomeViewModel : ObservableObject
|
||||
downloadSummaries.TryAdd("Talent", new(serviceProvider, "命之座图标", "Talent"));
|
||||
}
|
||||
|
||||
if (!LocalSetting.Get(SettingKeys.StaticResourceV2Contract, false))
|
||||
if (StaticResource.IsContractUnfulfilled(SettingKeys.StaticResourceV2Contract))
|
||||
{
|
||||
downloadSummaries.TryAdd("AchievementIcon", new(serviceProvider, "成就图标", "AchievementIcon"));
|
||||
downloadSummaries.TryAdd("ItemIcon", new(serviceProvider, "物品图标", "ItemIcon"));
|
||||
@@ -110,7 +110,7 @@ internal class WelcomeViewModel : ObservableObject
|
||||
downloadSummaries.TryAdd("RelicIcon", new(serviceProvider, "圣遗物图标", "RelicIcon"));
|
||||
}
|
||||
|
||||
if (!LocalSetting.Get(SettingKeys.StaticResourceV3Contract, false))
|
||||
if (StaticResource.IsContractUnfulfilled(SettingKeys.StaticResourceV3Contract))
|
||||
{
|
||||
downloadSummaries.TryAdd("Skill", new(serviceProvider, "天赋图标更新", "Skill"));
|
||||
downloadSummaries.TryAdd("Talent", new(serviceProvider, "命之座图标更新", "Talent"));
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Snap.Hutao.Web.Bridge;
|
||||
/// <summary>
|
||||
/// 调用桥
|
||||
/// </summary>
|
||||
[SuppressMessage("", "CA1001")]
|
||||
[SuppressMessage("", "SA1600")]
|
||||
public class MiHoYoJSInterface
|
||||
{
|
||||
@@ -67,7 +68,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="jsParam">参数</param>
|
||||
/// <returns>响应</returns>
|
||||
[JsMethod("getActionTicket")]
|
||||
public virtual async Task<IJsResult?> GetActionTicketAsync(JsParam<ActionTypePayload> jsParam)
|
||||
{
|
||||
User user = serviceProvider.GetRequiredService<IUserService>().Current!;
|
||||
@@ -82,7 +82,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>Http请求头</returns>
|
||||
[JsMethod("getHTTPRequestHeaders")]
|
||||
public virtual JsResult<Dictionary<string, string>> GetHttpRequestHeader(JsParam param)
|
||||
{
|
||||
return new()
|
||||
@@ -101,7 +100,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>响应</returns>
|
||||
[JsMethod("getCookieInfo")]
|
||||
public virtual JsResult<Dictionary<string, string>> GetCookieInfo(JsParam param)
|
||||
{
|
||||
User user = serviceProvider.GetRequiredService<IUserService>().Current!;
|
||||
@@ -122,7 +120,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>响应</returns>
|
||||
[JsMethod("getDS")]
|
||||
public virtual JsResult<Dictionary<string, string>> GetDynamicSecrectV1(JsParam param)
|
||||
{
|
||||
string salt = Core.CoreEnvironment.DynamicSecrets[nameof(SaltType.LK2)];
|
||||
@@ -153,7 +150,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>响应</returns>
|
||||
[JsMethod("getDS2")]
|
||||
public virtual JsResult<Dictionary<string, string>> GetDynamicSecrectV2(JsParam<DynamicSecrect2Playload> param)
|
||||
{
|
||||
string salt = Core.CoreEnvironment.DynamicSecrets[nameof(SaltType.X4)];
|
||||
@@ -177,7 +173,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>响应</returns>
|
||||
[JsMethod("getUserInfo")]
|
||||
public virtual JsResult<Dictionary<string, object>> GetUserInfo(JsParam param)
|
||||
{
|
||||
User user = serviceProvider.GetRequiredService<IUserService>().Current!;
|
||||
@@ -201,7 +196,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>响应</returns>
|
||||
[JsMethod("getCookieToken")]
|
||||
public virtual async Task<JsResult<Dictionary<string, string>>> GetCookieTokenAsync(JsParam<CookieTokenPayload> param)
|
||||
{
|
||||
User user = serviceProvider.GetRequiredService<IUserService>().Current!;
|
||||
@@ -237,7 +231,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>响应</returns>
|
||||
[JsMethod("closePage")]
|
||||
public virtual IJsResult? ClosePage(JsParam param)
|
||||
{
|
||||
ClosePageRequested?.Invoke();
|
||||
@@ -249,7 +242,6 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>响应</returns>
|
||||
[JsMethod("configure_share")]
|
||||
public virtual IJsResult? ConfigureShare(JsParam param)
|
||||
{
|
||||
return null;
|
||||
@@ -260,68 +252,57 @@ public class MiHoYoJSInterface
|
||||
/// </summary>
|
||||
/// <param name="param">参数</param>
|
||||
/// <returns>结果</returns>
|
||||
[JsMethod("getStatusBarHeight")]
|
||||
public virtual JsResult<Dictionary<string, object>> GetStatusBarHeight(JsParam param)
|
||||
{
|
||||
return new() { Data = new() { ["statusBarHeight"] = 0 } };
|
||||
}
|
||||
|
||||
[JsMethod("pushPage")]
|
||||
public virtual IJsResult? PushPage(JsParam<PushPagePayload> param)
|
||||
{
|
||||
webView.Navigate(param.Payload.Page);
|
||||
return null;
|
||||
}
|
||||
|
||||
[JsMethod("showAlertDialog")]
|
||||
public virtual Task<IJsResult?> ShowAlertDialogAsync(JsParam param)
|
||||
{
|
||||
return Task.FromException<IJsResult?>(new NotImplementedException());
|
||||
}
|
||||
|
||||
[JsMethod("startRealPersonValidation")]
|
||||
public virtual IJsResult? StartRealPersonValidation(JsParam param)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[JsMethod("startRealnameAuth")]
|
||||
public virtual IJsResult? StartRealnameAuth(JsParam param)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[JsMethod("genAuthKey")]
|
||||
public virtual IJsResult? GenAuthKey(JsParam param)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[JsMethod("genAppAuthKey")]
|
||||
public virtual IJsResult? GenAppAuthKey(JsParam param)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[JsMethod("openSystemBrowser")]
|
||||
public virtual IJsResult? OpenSystemBrowser(JsParam param)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[JsMethod("saveLoginTicket")]
|
||||
public virtual IJsResult? SaveLoginTicket(JsParam param)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[JsMethod("getNotificationSettings")]
|
||||
public virtual Task<IJsResult?> GetNotificationSettingsAsync(JsParam param)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[JsMethod("showToast")]
|
||||
public virtual IJsResult? ShowToast(JsParam param)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
Reference in New Issue
Block a user