mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Compare commits
17 Commits
feat/windo
...
feat/hypap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
702a3d0e62 | ||
|
|
176535ca98 | ||
|
|
36eab42692 | ||
|
|
75ea2b807f | ||
|
|
e8eed46d82 | ||
|
|
ff9b553a19 | ||
|
|
95d64c2895 | ||
|
|
558551c8ad | ||
|
|
d05c196b7c | ||
|
|
502fb6dbed | ||
|
|
4fa5270070 | ||
|
|
94fda223fc | ||
|
|
18103b4deb | ||
|
|
16ac52e71d | ||
|
|
73825d391e | ||
|
|
3b2eeb84a7 | ||
|
|
3e8655fd55 |
2
.github/ISSUE_TEMPLATE/CHS-bug-report.yml
vendored
2
.github/ISSUE_TEMPLATE/CHS-bug-report.yml
vendored
@@ -19,7 +19,7 @@ body:
|
|||||||
- label: 我已阅读 Snap Hutao 文档中的[常见问题](https://hut.ao/advanced/FAQ.html)和[常见程序异常](https://hut.ao/advanced/exceptions.html),我的问题没有在文档中得到解答
|
- label: 我已阅读 Snap Hutao 文档中的[常见问题](https://hut.ao/advanced/FAQ.html)和[常见程序异常](https://hut.ao/advanced/exceptions.html),我的问题没有在文档中得到解答
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- label: 我知道文档站的导航栏中有**搜索功能**,且已经搜索过相关关键词
|
- label: 我知道[文档站](https://hut.ao/zh/menu.html)的导航栏中有**搜索功能**,且已经搜索过相关关键词
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- label: 我的问题不是[已完成](https://github.com/DGP-Studio/Snap.Hutao/issues?q=is%3Aopen+is%3Aissue+label%3A%E5%B7%B2%E5%AE%8C%E6%88%90)的问题也不是一个别人已发布的**重复的**问题
|
- label: 我的问题不是[已完成](https://github.com/DGP-Studio/Snap.Hutao/issues?q=is%3Aopen+is%3Aissue+label%3A%E5%B7%B2%E5%AE%8C%E6%88%90)的问题也不是一个别人已发布的**重复的**问题
|
||||||
|
|||||||
8
.github/workflows/alpha.yml
vendored
8
.github/workflows/alpha.yml
vendored
@@ -67,9 +67,7 @@ jobs:
|
|||||||
> 普通用户请 [点击这里](https://github.com/DGP-Studio/Snap.Hutao/releases/latest/) 下载最新的稳定版本
|
> 普通用户请 [点击这里](https://github.com/DGP-Studio/Snap.Hutao/releases/latest/) 下载最新的稳定版本
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> 请注意,从 Snap Hutao Alpha 2023.12.21.3 开始,我们将使用全新的 CI 证书,原有的 Snap.Hutao.CI.cer 将在几天后过期停止使用。
|
> 请先安装 **[DGP_Studio_CA.crt](https://github.com/DGP-Automation/Hutao-Auto-Release/releases/download/certificate-ca/DGP_Studio_CA.crt)** 到 **受信任的根证书颁发机构** 以安装测试版安装包
|
||||||
>
|
|
||||||
> 请安装 [DGP_Studio_CA.crt](https://github.com/DGP-Automation/Hutao-Auto-Release/releases/download/certificate-ca/DGP_Studio_CA.crt) 到 `受信任的根证书颁发机构` 以安装测试版安装包
|
|
||||||
"
|
"
|
||||||
|
|
||||||
echo $summary >> $Env:GITHUB_STEP_SUMMARY
|
echo $summary >> $Env:GITHUB_STEP_SUMMARY
|
||||||
@@ -114,9 +112,7 @@ jobs:
|
|||||||
> 普通用户请 [点击这里](https://github.com/DGP-Studio/Snap.Hutao/releases/latest/) 下载最新的稳定版本
|
> 普通用户请 [点击这里](https://github.com/DGP-Studio/Snap.Hutao/releases/latest/) 下载最新的稳定版本
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> 请注意,从 Snap Hutao Alpha 2023.12.21.3 开始,我们将使用全新的 CI 证书,原有的 Snap.Hutao.CI.cer 将在几天后过期停止使用。
|
> 请先安装 **[DGP_Studio_CA.crt](https://github.com/DGP-Automation/Hutao-Auto-Release/releases/download/certificate-ca/DGP_Studio_CA.crt)** 到 **受信任的根证书颁发机构** 以安装测试版安装包
|
||||||
>
|
|
||||||
> 请安装 [DGP_Studio_CA.crt](https://github.com/DGP-Automation/Hutao-Auto-Release/releases/download/certificate-ca/DGP_Studio_CA.crt) 到 `受信任的根证书颁发机构` 以安装测试版安装包
|
|
||||||
"
|
"
|
||||||
|
|
||||||
echo $summary >> $Env:GITHUB_STEP_SUMMARY
|
echo $summary >> $Env:GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
using Microsoft.Windows.AppLifecycle;
|
using Microsoft.Windows.AppLifecycle;
|
||||||
|
using Microsoft.Windows.AppNotifications;
|
||||||
using Snap.Hutao.Core;
|
using Snap.Hutao.Core;
|
||||||
using Snap.Hutao.Core.ExceptionService;
|
using Snap.Hutao.Core.ExceptionService;
|
||||||
using Snap.Hutao.Core.LifeCycle;
|
using Snap.Hutao.Core.LifeCycle;
|
||||||
@@ -68,6 +69,10 @@ public sealed partial class App : Application
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Important: You must call AppNotificationManager::Default().Register
|
||||||
|
// before calling AppInstance.GetCurrent.GetActivatedEventArgs.
|
||||||
|
AppNotificationManager.Default.NotificationInvoked += activation.NotificationInvoked;
|
||||||
|
AppNotificationManager.Default.Register();
|
||||||
AppActivationArguments activatedEventArgs = AppInstance.GetCurrent().GetActivatedEventArgs();
|
AppActivationArguments activatedEventArgs = AppInstance.GetCurrent().GetActivatedEventArgs();
|
||||||
|
|
||||||
if (serviceProvider.GetRequiredService<PrivateNamedPipeClient>().TryRedirectActivationTo(activatedEventArgs))
|
if (serviceProvider.GetRequiredService<PrivateNamedPipeClient>().TryRedirectActivationTo(activatedEventArgs))
|
||||||
@@ -81,14 +86,7 @@ public sealed partial class App : Application
|
|||||||
LogDiagnosticInformation();
|
LogDiagnosticInformation();
|
||||||
|
|
||||||
// Manually invoke
|
// Manually invoke
|
||||||
HutaoActivationArguments hutaoArgs = HutaoActivationArguments.FromAppActivationArguments(activatedEventArgs);
|
activation.Activate(HutaoActivationArguments.FromAppActivationArguments(activatedEventArgs));
|
||||||
if (hutaoArgs.Kind is HutaoActivationKind.Toast)
|
|
||||||
{
|
|
||||||
Exit();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
activation.Activate(hutaoArgs);
|
|
||||||
activation.PostInitialization();
|
activation.PostInitialization();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<shmmc:AchievementIconConverter x:Key="AchievementIconConverter"/>
|
<shmmc:AchievementIconConverter x:Key="AchievementIconConverter"/>
|
||||||
<shmmc:AvatarCardConverter x:Key="AvatarCardConverter"/>
|
<shmmc:AvatarCardConverter x:Key="AvatarCardConverter"/>
|
||||||
<shmmc:AvatarIconConverter x:Key="AvatarIconConverter"/>
|
<shmmc:AvatarIconConverter x:Key="AvatarIconConverter"/>
|
||||||
|
<shmmc:AvatarIconCircleConverter x:Key="AvatarIconCircleConverter"/>
|
||||||
<shmmc:AvatarNameCardPicConverter x:Key="AvatarNameCardPicConverter"/>
|
<shmmc:AvatarNameCardPicConverter x:Key="AvatarNameCardPicConverter"/>
|
||||||
<shmmc:AvatarSideIconConverter x:Key="AvatarSideIconConverter"/>
|
<shmmc:AvatarSideIconConverter x:Key="AvatarSideIconConverter"/>
|
||||||
<shmmc:DescriptionsParametersDescriptor x:Key="DescParamDescriptor"/>
|
<shmmc:DescriptionsParametersDescriptor x:Key="DescParamDescriptor"/>
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
<CornerRadius x:Key="ControlCornerRadiusTop">4,4,0,0</CornerRadius>
|
<CornerRadius x:Key="ControlCornerRadiusTop">4,4,0,0</CornerRadius>
|
||||||
<CornerRadius x:Key="ControlCornerRadiusBottom">0,0,4,4</CornerRadius>
|
<CornerRadius x:Key="ControlCornerRadiusBottom">0,0,4,4</CornerRadius>
|
||||||
<CornerRadius x:Key="ControlCornerRadiusTopRightAndBottomLeft">0,4,0,4</CornerRadius>
|
<CornerRadius x:Key="ControlCornerRadiusTopRightAndBottomLeft">0,4,0,4</CornerRadius>
|
||||||
|
<CornerRadius x:Key="CornerRadiusAll16">16</CornerRadius>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// 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 CommunityToolkit.WinUI.Notifications;
|
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.Windows.AppNotifications;
|
||||||
using Snap.Hutao.Core.LifeCycle.InterProcess;
|
using Snap.Hutao.Core.LifeCycle.InterProcess;
|
||||||
using Snap.Hutao.Core.Setting;
|
using Snap.Hutao.Core.Setting;
|
||||||
using Snap.Hutao.Core.Shell;
|
using Snap.Hutao.Core.Shell;
|
||||||
@@ -11,7 +11,6 @@ using Snap.Hutao.Core.Windowing;
|
|||||||
using Snap.Hutao.Core.Windowing.HotKey;
|
using Snap.Hutao.Core.Windowing.HotKey;
|
||||||
using Snap.Hutao.Core.Windowing.NotifyIcon;
|
using Snap.Hutao.Core.Windowing.NotifyIcon;
|
||||||
using Snap.Hutao.Service;
|
using Snap.Hutao.Service;
|
||||||
using Snap.Hutao.Service.DailyNote;
|
|
||||||
using Snap.Hutao.Service.Discord;
|
using Snap.Hutao.Service.Discord;
|
||||||
using Snap.Hutao.Service.Hutao;
|
using Snap.Hutao.Service.Hutao;
|
||||||
using Snap.Hutao.Service.Job;
|
using Snap.Hutao.Service.Job;
|
||||||
@@ -37,12 +36,10 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
|
|||||||
public const string ImportUIAFFromClipboard = nameof(ImportUIAFFromClipboard);
|
public const string ImportUIAFFromClipboard = nameof(ImportUIAFFromClipboard);
|
||||||
|
|
||||||
private const string CategoryAchievement = "ACHIEVEMENT";
|
private const string CategoryAchievement = "ACHIEVEMENT";
|
||||||
private const string CategoryDailyNote = "DAILYNOTE";
|
|
||||||
private const string UrlActionImport = "/IMPORT";
|
private const string UrlActionImport = "/IMPORT";
|
||||||
private const string UrlActionRefresh = "/REFRESH";
|
|
||||||
|
|
||||||
private readonly IServiceProvider serviceProvider;
|
|
||||||
private readonly ICurrentXamlWindowReference currentWindowReference;
|
private readonly ICurrentXamlWindowReference currentWindowReference;
|
||||||
|
private readonly IServiceProvider serviceProvider;
|
||||||
private readonly ITaskContext taskContext;
|
private readonly ITaskContext taskContext;
|
||||||
|
|
||||||
private readonly SemaphoreSlim activateSemaphore = new(1);
|
private readonly SemaphoreSlim activateSemaphore = new(1);
|
||||||
@@ -50,7 +47,47 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Activate(HutaoActivationArguments args)
|
public void Activate(HutaoActivationArguments args)
|
||||||
{
|
{
|
||||||
HandleActivationAsync(args).SafeForget();
|
HandleActivationExclusiveAsync(args).SafeForget();
|
||||||
|
|
||||||
|
async ValueTask HandleActivationExclusiveAsync(HutaoActivationArguments args)
|
||||||
|
{
|
||||||
|
await taskContext.SwitchToBackgroundAsync();
|
||||||
|
|
||||||
|
if (activateSemaphore.CurrentCount > 0)
|
||||||
|
{
|
||||||
|
using (await activateSemaphore.EnterAsync().ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
switch (args.Kind)
|
||||||
|
{
|
||||||
|
case HutaoActivationKind.Protocol:
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(args.ProtocolActivatedUri);
|
||||||
|
await HandleProtocolActivationAsync(args.ProtocolActivatedUri, args.IsRedirectTo).ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case HutaoActivationKind.Launch:
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(args.LaunchActivatedArguments);
|
||||||
|
await HandleLaunchActivationAsync(args.IsRedirectTo).ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case HutaoActivationKind.AppNotification:
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(args.AppNotificationActivatedArguments);
|
||||||
|
await HandleAppNotificationActivationAsync(args.AppNotificationActivatedArguments, args.IsRedirectTo).ConfigureAwait(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NotificationInvoked(AppNotificationManager manager, AppNotificationActivatedEventArgs args)
|
||||||
|
{
|
||||||
|
HandleAppNotificationActivationAsync(args.Arguments, false).SafeForget();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -62,20 +99,22 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
|
|||||||
{
|
{
|
||||||
await taskContext.SwitchToBackgroundAsync();
|
await taskContext.SwitchToBackgroundAsync();
|
||||||
|
|
||||||
serviceProvider.GetRequiredService<PrivateNamedPipeServer>().RunAsync().SafeForget();
|
|
||||||
ToastNotificationManagerCompat.OnActivated += NotificationActivate;
|
|
||||||
|
|
||||||
using (await activateSemaphore.EnterAsync().ConfigureAwait(false))
|
using (await activateSemaphore.EnterAsync().ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
// TODO: Introduced in 1.10.2, remove in later version
|
// TODO: Introduced in 1.10.2, remove in later version
|
||||||
|
{
|
||||||
serviceProvider.GetRequiredService<IJumpListInterop>().ClearAsync().SafeForget();
|
serviceProvider.GetRequiredService<IJumpListInterop>().ClearAsync().SafeForget();
|
||||||
serviceProvider.GetRequiredService<IScheduleTaskInterop>().UnregisterAllTasks();
|
serviceProvider.GetRequiredService<IScheduleTaskInterop>().UnregisterAllTasks();
|
||||||
|
}
|
||||||
|
|
||||||
if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor10Revision0GuideState, GuideState.Language) < GuideState.Completed)
|
if (UnsafeLocalSetting.Get(SettingKeys.Major1Minor10Revision0GuideState, GuideState.Language) < GuideState.Completed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serviceProvider.GetRequiredService<PrivateNamedPipeServer>().RunAsync().SafeForget();
|
||||||
|
|
||||||
|
// RegisterHotKey should be called from main thread
|
||||||
await taskContext.SwitchToMainThreadAsync();
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
serviceProvider.GetRequiredService<HotKeyOptions>().RegisterAll();
|
serviceProvider.GetRequiredService<HotKeyOptions>().RegisterAll();
|
||||||
|
|
||||||
@@ -88,7 +127,18 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
|
|||||||
_ = serviceProvider.GetRequiredService<NotifyIconController>();
|
_ = serviceProvider.GetRequiredService<NotifyIconController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceProvider.GetRequiredService<IQuartzService>().StartAsync(default).SafeForget();
|
serviceProvider.GetRequiredService<IDiscordService>().SetNormalActivityAsync().SafeForget();
|
||||||
|
serviceProvider.GetRequiredService<IQuartzService>().StartAsync().SafeForget();
|
||||||
|
|
||||||
|
if (serviceProvider.GetRequiredService<IMetadataService>() is IMetadataServiceInitialization metadataServiceInitialization)
|
||||||
|
{
|
||||||
|
metadataServiceInitialization.InitializeInternalAsync().SafeForget();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serviceProvider.GetRequiredService<IHutaoUserService>() is IHutaoUserServiceInitialization hutaoUserServiceInitialization)
|
||||||
|
{
|
||||||
|
hutaoUserServiceInitialization.InitializeInternalAsync().SafeForget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,55 +184,52 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NotificationActivate(ToastNotificationActivatedEventArgsCompat args)
|
private async ValueTask HandleProtocolActivationAsync(Uri uri, bool isRedirectTo)
|
||||||
{
|
{
|
||||||
ToastArguments toastArgs = ToastArguments.Parse(args.Argument);
|
UriBuilder builder = new(uri);
|
||||||
|
|
||||||
if (toastArgs.TryGetValue(Action, out string? action))
|
string category = builder.Host.ToUpperInvariant();
|
||||||
|
string action = builder.Path.ToUpperInvariant();
|
||||||
|
|
||||||
|
// string parameter = builder.Query.ToUpperInvariant();
|
||||||
|
switch (category)
|
||||||
{
|
{
|
||||||
if (action == LaunchGame)
|
case CategoryAchievement:
|
||||||
{
|
{
|
||||||
_ = toastArgs.TryGetValue(Uid, out string? uid);
|
await WaitMainWindowOrCurrentAsync().ConfigureAwait(false);
|
||||||
HandleLaunchGameActionAsync(uid).SafeForget();
|
if (currentWindowReference.Window is not MainWindow)
|
||||||
|
{
|
||||||
|
// TODO: Send notification to hint?
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case UrlActionImport:
|
||||||
|
{
|
||||||
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
|
|
||||||
|
INavigationAwaiter navigationAwaiter = new NavigationExtra(ImportUIAFFromClipboard);
|
||||||
|
await serviceProvider
|
||||||
|
.GetRequiredService<INavigationService>()
|
||||||
|
.NavigateAsync<View.Page.AchievementPage>(navigationAwaiter, true)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ValueTask HandleActivationAsync(HutaoActivationArguments args)
|
break;
|
||||||
{
|
|
||||||
await taskContext.SwitchToBackgroundAsync();
|
|
||||||
|
|
||||||
if (activateSemaphore.CurrentCount > 0)
|
|
||||||
{
|
|
||||||
using (await activateSemaphore.EnterAsync().ConfigureAwait(false))
|
|
||||||
{
|
|
||||||
await HandleActivationCoreAsync(args).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ValueTask HandleActivationCoreAsync(HutaoActivationArguments args)
|
|
||||||
{
|
|
||||||
if (args.Kind is HutaoActivationKind.Protocol)
|
|
||||||
{
|
|
||||||
ArgumentNullException.ThrowIfNull(args.ProtocolActivatedUri);
|
|
||||||
await HandleUrlActivationAsync(args.ProtocolActivatedUri, args.IsRedirectTo).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
else if (args.Kind is HutaoActivationKind.Launch)
|
|
||||||
{
|
|
||||||
ArgumentNullException.ThrowIfNull(args.LaunchActivatedArguments);
|
|
||||||
switch (args.LaunchActivatedArguments)
|
|
||||||
{
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
await HandleNormalLaunchActionAsync(args.IsRedirectTo).ConfigureAwait(false);
|
await HandleLaunchActivationAsync(isRedirectTo).ConfigureAwait(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async ValueTask HandleNormalLaunchActionAsync(bool isRedirectTo)
|
private async ValueTask HandleLaunchActivationAsync(bool isRedirectTo)
|
||||||
{
|
{
|
||||||
if (!isRedirectTo)
|
if (!isRedirectTo)
|
||||||
{
|
{
|
||||||
@@ -214,6 +261,22 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
|
|||||||
await WaitMainWindowOrCurrentAsync().ConfigureAwait(false);
|
await WaitMainWindowOrCurrentAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async ValueTask HandleAppNotificationActivationAsync(IDictionary<string, string> arguments, bool isRedirectTo)
|
||||||
|
{
|
||||||
|
if (arguments.TryGetValue(Action, out string? action))
|
||||||
|
{
|
||||||
|
if (action == LaunchGame)
|
||||||
|
{
|
||||||
|
_ = arguments.TryGetValue(Uid, out string? uid);
|
||||||
|
await HandleLaunchGameActionAsync(uid).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await HandleLaunchActivationAsync(isRedirectTo).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async ValueTask WaitMainWindowOrCurrentAsync()
|
private async ValueTask WaitMainWindowOrCurrentAsync()
|
||||||
{
|
{
|
||||||
if (currentWindowReference.Window is { } window)
|
if (currentWindowReference.Window is { } window)
|
||||||
@@ -230,100 +293,5 @@ internal sealed partial class AppActivation : IAppActivation, IAppActivationActi
|
|||||||
|
|
||||||
mainWindow.SwitchTo();
|
mainWindow.SwitchTo();
|
||||||
mainWindow.BringToForeground();
|
mainWindow.BringToForeground();
|
||||||
|
|
||||||
await taskContext.SwitchToBackgroundAsync();
|
|
||||||
|
|
||||||
if (serviceProvider.GetRequiredService<IMetadataService>() is IMetadataServiceInitialization metadataServiceInitialization)
|
|
||||||
{
|
|
||||||
metadataServiceInitialization.InitializeInternalAsync().SafeForget();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serviceProvider.GetRequiredService<IHutaoUserService>() is IHutaoUserServiceInitialization hutaoUserServiceInitialization)
|
|
||||||
{
|
|
||||||
hutaoUserServiceInitialization.InitializeInternalAsync().SafeForget();
|
|
||||||
}
|
|
||||||
|
|
||||||
serviceProvider.GetRequiredService<IDiscordService>().SetNormalActivityAsync().SafeForget();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async ValueTask HandleUrlActivationAsync(Uri uri, bool isRedirectTo)
|
|
||||||
{
|
|
||||||
UriBuilder builder = new(uri);
|
|
||||||
|
|
||||||
string category = builder.Host.ToUpperInvariant();
|
|
||||||
string action = builder.Path.ToUpperInvariant();
|
|
||||||
string parameter = builder.Query.ToUpperInvariant();
|
|
||||||
|
|
||||||
switch (category)
|
|
||||||
{
|
|
||||||
case CategoryAchievement:
|
|
||||||
{
|
|
||||||
await WaitMainWindowOrCurrentAsync().ConfigureAwait(false);
|
|
||||||
await HandleAchievementActionAsync(action, parameter, isRedirectTo).ConfigureAwait(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case CategoryDailyNote:
|
|
||||||
{
|
|
||||||
await HandleDailyNoteActionAsync(action, parameter, isRedirectTo).ConfigureAwait(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
await HandleNormalLaunchActionAsync(isRedirectTo).ConfigureAwait(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async ValueTask HandleAchievementActionAsync(string action, string parameter, bool isRedirectTo)
|
|
||||||
{
|
|
||||||
_ = parameter;
|
|
||||||
_ = isRedirectTo;
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case UrlActionImport:
|
|
||||||
{
|
|
||||||
await taskContext.SwitchToMainThreadAsync();
|
|
||||||
|
|
||||||
INavigationAwaiter navigationAwaiter = new NavigationExtra(ImportUIAFFromClipboard);
|
|
||||||
await serviceProvider
|
|
||||||
.GetRequiredService<INavigationService>()
|
|
||||||
.NavigateAsync<View.Page.AchievementPage>(navigationAwaiter, true)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async ValueTask HandleDailyNoteActionAsync(string action, string parameter, bool isRedirectTo)
|
|
||||||
{
|
|
||||||
_ = parameter;
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case UrlActionRefresh:
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await serviceProvider
|
|
||||||
.GetRequiredService<IDailyNoteService>()
|
|
||||||
.RefreshDailyNotesAsync()
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if it's redirected.
|
|
||||||
if (!isRedirectTo)
|
|
||||||
{
|
|
||||||
// It's a direct open process, should exit immediately.
|
|
||||||
Process.GetCurrentProcess().Kill();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
using Microsoft.Windows.AppLifecycle;
|
using Microsoft.Windows.AppLifecycle;
|
||||||
|
using Microsoft.Windows.AppNotifications;
|
||||||
using Windows.ApplicationModel.Activation;
|
using Windows.ApplicationModel.Activation;
|
||||||
|
|
||||||
namespace Snap.Hutao.Core.LifeCycle;
|
namespace Snap.Hutao.Core.LifeCycle;
|
||||||
@@ -12,12 +13,6 @@ namespace Snap.Hutao.Core.LifeCycle;
|
|||||||
[HighQuality]
|
[HighQuality]
|
||||||
internal static class AppActivationArgumentsExtensions
|
internal static class AppActivationArgumentsExtensions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 尝试获取协议启动的Uri
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="activatedEventArgs">应用程序激活参数</param>
|
|
||||||
/// <param name="uri">协议Uri</param>
|
|
||||||
/// <returns>是否存在协议Uri</returns>
|
|
||||||
public static bool TryGetProtocolActivatedUri(this AppActivationArguments activatedEventArgs, [NotNullWhen(true)] out Uri? uri)
|
public static bool TryGetProtocolActivatedUri(this AppActivationArguments activatedEventArgs, [NotNullWhen(true)] out Uri? uri)
|
||||||
{
|
{
|
||||||
uri = null;
|
uri = null;
|
||||||
@@ -30,15 +25,10 @@ internal static class AppActivationArgumentsExtensions
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 尝试获取启动的参数
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="activatedEventArgs">应用程序激活参数</param>
|
|
||||||
/// <param name="arguments">参数</param>
|
|
||||||
/// <returns>是否存在参数</returns>
|
|
||||||
public static bool TryGetLaunchActivatedArguments(this AppActivationArguments activatedEventArgs, [NotNullWhen(true)] out string? arguments)
|
public static bool TryGetLaunchActivatedArguments(this AppActivationArguments activatedEventArgs, [NotNullWhen(true)] out string? arguments)
|
||||||
{
|
{
|
||||||
arguments = null;
|
arguments = null;
|
||||||
|
|
||||||
if (activatedEventArgs.Data is not ILaunchActivatedEventArgs launchArgs)
|
if (activatedEventArgs.Data is not ILaunchActivatedEventArgs launchArgs)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -47,4 +37,21 @@ internal static class AppActivationArgumentsExtensions
|
|||||||
arguments = launchArgs.Arguments.Trim();
|
arguments = launchArgs.Arguments.Trim();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool TryGetAppNotificationActivatedArguments(this AppActivationArguments activatedEventArgs, out string? argument, [NotNullWhen(true)] out IDictionary<string, string>? arguments, [NotNullWhen(true)] out IDictionary<string, string>? userInput)
|
||||||
|
{
|
||||||
|
argument = null;
|
||||||
|
arguments = null;
|
||||||
|
userInput = null;
|
||||||
|
|
||||||
|
if (activatedEventArgs.Data is not AppNotificationActivatedEventArgs appNotificationArgs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
argument = appNotificationArgs.Argument;
|
||||||
|
arguments = appNotificationArgs.Arguments;
|
||||||
|
userInput = appNotificationArgs.UserInput;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
// 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 Microsoft.Extensions.Primitives;
|
|
||||||
using Microsoft.Windows.AppLifecycle;
|
using Microsoft.Windows.AppLifecycle;
|
||||||
|
|
||||||
namespace Snap.Hutao.Core.LifeCycle;
|
namespace Snap.Hutao.Core.LifeCycle;
|
||||||
@@ -10,14 +9,16 @@ internal sealed class HutaoActivationArguments
|
|||||||
{
|
{
|
||||||
public bool IsRedirectTo { get; set; }
|
public bool IsRedirectTo { get; set; }
|
||||||
|
|
||||||
public bool IsToastActivated { get; set; }
|
|
||||||
|
|
||||||
public HutaoActivationKind Kind { get; set; }
|
public HutaoActivationKind Kind { get; set; }
|
||||||
|
|
||||||
public Uri? ProtocolActivatedUri { get; set; }
|
public Uri? ProtocolActivatedUri { get; set; }
|
||||||
|
|
||||||
public string? LaunchActivatedArguments { get; set; }
|
public string? LaunchActivatedArguments { get; set; }
|
||||||
|
|
||||||
|
public IDictionary<string, string>? AppNotificationActivatedArguments { get; set; }
|
||||||
|
|
||||||
|
public IDictionary<string, string>? AppNotificationActivatedUserInput { get; set; }
|
||||||
|
|
||||||
public static HutaoActivationArguments FromAppActivationArguments(AppActivationArguments args, bool isRedirected = false)
|
public static HutaoActivationArguments FromAppActivationArguments(AppActivationArguments args, bool isRedirected = false)
|
||||||
{
|
{
|
||||||
HutaoActivationArguments result = new()
|
HutaoActivationArguments result = new()
|
||||||
@@ -33,15 +34,6 @@ internal sealed class HutaoActivationArguments
|
|||||||
if (args.TryGetLaunchActivatedArguments(out string? arguments))
|
if (args.TryGetLaunchActivatedArguments(out string? arguments))
|
||||||
{
|
{
|
||||||
result.LaunchActivatedArguments = arguments;
|
result.LaunchActivatedArguments = arguments;
|
||||||
|
|
||||||
foreach (StringSegment segment in new StringTokenizer(arguments, [' ']))
|
|
||||||
{
|
|
||||||
if (segment.AsSpan().SequenceEqual("-ToastActivated"))
|
|
||||||
{
|
|
||||||
result.Kind = HutaoActivationKind.Toast;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -55,6 +47,19 @@ internal sealed class HutaoActivationArguments
|
|||||||
result.ProtocolActivatedUri = uri;
|
result.ProtocolActivatedUri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ExtendedActivationKind.AppNotification:
|
||||||
|
{
|
||||||
|
result.Kind = HutaoActivationKind.AppNotification;
|
||||||
|
if (args.TryGetAppNotificationActivatedArguments(out string? argument, out IDictionary<string, string>? arguments, out IDictionary<string, string>? userInput))
|
||||||
|
{
|
||||||
|
result.LaunchActivatedArguments = argument;
|
||||||
|
result.AppNotificationActivatedArguments = arguments;
|
||||||
|
result.AppNotificationActivatedUserInput = userInput;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ internal enum HutaoActivationKind
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Launch,
|
Launch,
|
||||||
Toast,
|
AppNotification,
|
||||||
Protocol,
|
Protocol,
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
// 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 Microsoft.Windows.AppNotifications;
|
||||||
|
|
||||||
namespace Snap.Hutao.Core.LifeCycle;
|
namespace Snap.Hutao.Core.LifeCycle;
|
||||||
|
|
||||||
internal interface IAppActivation
|
internal interface IAppActivation
|
||||||
{
|
{
|
||||||
void Activate(HutaoActivationArguments args);
|
void Activate(HutaoActivationArguments args);
|
||||||
|
|
||||||
|
void NotificationInvoked(AppNotificationManager manager, AppNotificationActivatedEventArgs args);
|
||||||
|
|
||||||
void PostInitialization();
|
void PostInitialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal interface IAppActivationActionHandlersAccess
|
|
||||||
{
|
|
||||||
ValueTask HandleLaunchGameActionAsync(string? uid = null);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Core.LifeCycle;
|
||||||
|
|
||||||
|
internal interface IAppActivationActionHandlersAccess
|
||||||
|
{
|
||||||
|
ValueTask HandleLaunchGameActionAsync(string? uid = null);
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ internal sealed partial class PrivateNamedPipeServer : IDisposable
|
|||||||
{
|
{
|
||||||
private readonly PrivateNamedPipeMessageDispatcher messageDispatcher;
|
private readonly PrivateNamedPipeMessageDispatcher messageDispatcher;
|
||||||
private readonly RuntimeOptions runtimeOptions;
|
private readonly RuntimeOptions runtimeOptions;
|
||||||
|
private readonly ILogger<PrivateNamedPipeServer> logger;
|
||||||
|
|
||||||
private readonly CancellationTokenSource serverTokenSource = new();
|
private readonly CancellationTokenSource serverTokenSource = new();
|
||||||
private readonly SemaphoreSlim serverSemaphore = new(1);
|
private readonly SemaphoreSlim serverSemaphore = new(1);
|
||||||
@@ -23,6 +24,7 @@ internal sealed partial class PrivateNamedPipeServer : IDisposable
|
|||||||
{
|
{
|
||||||
messageDispatcher = serviceProvider.GetRequiredService<PrivateNamedPipeMessageDispatcher>();
|
messageDispatcher = serviceProvider.GetRequiredService<PrivateNamedPipeMessageDispatcher>();
|
||||||
runtimeOptions = serviceProvider.GetRequiredService<RuntimeOptions>();
|
runtimeOptions = serviceProvider.GetRequiredService<RuntimeOptions>();
|
||||||
|
logger = serviceProvider.GetRequiredService<ILogger<PrivateNamedPipeServer>>();
|
||||||
|
|
||||||
PipeSecurity? pipeSecurity = default;
|
PipeSecurity? pipeSecurity = default;
|
||||||
|
|
||||||
@@ -64,6 +66,7 @@ internal sealed partial class PrivateNamedPipeServer : IDisposable
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await serverStream.WaitForConnectionAsync(serverTokenSource.Token).ConfigureAwait(false);
|
await serverStream.WaitForConnectionAsync(serverTokenSource.Token).ConfigureAwait(false);
|
||||||
|
logger.LogInformation("Pipe session created");
|
||||||
RunPacketSession(serverStream, serverTokenSource.Token);
|
RunPacketSession(serverStream, serverTokenSource.Token);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
@@ -78,6 +81,7 @@ internal sealed partial class PrivateNamedPipeServer : IDisposable
|
|||||||
while (serverStream.IsConnected && !token.IsCancellationRequested)
|
while (serverStream.IsConnected && !token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
serverStream.ReadPacket(out PipePacketHeader header);
|
serverStream.ReadPacket(out PipePacketHeader header);
|
||||||
|
logger.LogInformation("Pipe packet: [Type:{Type}] [Command:{Command}]", header.Type, header.Command);
|
||||||
switch ((header.Type, header.Command))
|
switch ((header.Type, header.Command))
|
||||||
{
|
{
|
||||||
case (PipePacketType.Request, PipePacketCommand.RequestElevationStatus):
|
case (PipePacketType.Request, PipePacketCommand.RequestElevationStatus):
|
||||||
@@ -87,6 +91,11 @@ internal sealed partial class PrivateNamedPipeServer : IDisposable
|
|||||||
break;
|
break;
|
||||||
case (PipePacketType.Request, PipePacketCommand.RedirectActivation):
|
case (PipePacketType.Request, PipePacketCommand.RedirectActivation):
|
||||||
HutaoActivationArguments? hutaoArgs = serverStream.ReadJsonContent<HutaoActivationArguments>(in header);
|
HutaoActivationArguments? hutaoArgs = serverStream.ReadJsonContent<HutaoActivationArguments>(in header);
|
||||||
|
if (hutaoArgs is not null)
|
||||||
|
{
|
||||||
|
logger.LogInformation("Redirect activation: [Kind:{Kind}] [Arguments:{Arguments}]", hutaoArgs.Kind, hutaoArgs.LaunchActivatedArguments);
|
||||||
|
}
|
||||||
|
|
||||||
messageDispatcher.RedirectActivation(hutaoArgs);
|
messageDispatcher.RedirectActivation(hutaoArgs);
|
||||||
break;
|
break;
|
||||||
case (PipePacketType.SessionTermination, _):
|
case (PipePacketType.SessionTermination, _):
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ internal class AsyncBarrier
|
|||||||
/// <param name="participants">The number of participants.</param>
|
/// <param name="participants">The number of participants.</param>
|
||||||
public AsyncBarrier(int participants)
|
public AsyncBarrier(int participants)
|
||||||
{
|
{
|
||||||
ArgumentOutOfRangeException.ThrowIfLessThan(participants, 1, "Participants of AsyncBarrier can not be less than 1");
|
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(participants, "Participants of AsyncBarrier must be greater than 0");
|
||||||
participantCount = participants;
|
participantCount = participants;
|
||||||
|
|
||||||
// Allocate the stack so no resizing is necessary.
|
// Allocate the stack so no resizing is necessary.
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ using System.Runtime.CompilerServices;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Windows.Storage;
|
|
||||||
using static Snap.Hutao.Win32.ConstValues;
|
using static Snap.Hutao.Win32.ConstValues;
|
||||||
|
|
||||||
namespace Snap.Hutao.Core.Windowing.NotifyIcon;
|
namespace Snap.Hutao.Core.Windowing.NotifyIcon;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// 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 CommunityToolkit.WinUI.Notifications;
|
|
||||||
using Microsoft.UI;
|
using Microsoft.UI;
|
||||||
using Microsoft.UI.Composition.SystemBackdrops;
|
using Microsoft.UI.Composition.SystemBackdrops;
|
||||||
using Microsoft.UI.Content;
|
using Microsoft.UI.Content;
|
||||||
@@ -9,11 +8,11 @@ using Microsoft.UI.Input;
|
|||||||
using Microsoft.UI.Windowing;
|
using Microsoft.UI.Windowing;
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
using Microsoft.UI.Xaml.Media;
|
using Microsoft.UI.Xaml.Media;
|
||||||
|
using Microsoft.Windows.AppNotifications.Builder;
|
||||||
using Snap.Hutao.Core.LifeCycle;
|
using Snap.Hutao.Core.LifeCycle;
|
||||||
using Snap.Hutao.Core.Setting;
|
using Snap.Hutao.Core.Setting;
|
||||||
using Snap.Hutao.Core.Windowing.Abstraction;
|
using Snap.Hutao.Core.Windowing.Abstraction;
|
||||||
using Snap.Hutao.Core.Windowing.NotifyIcon;
|
using Snap.Hutao.Core.Windowing.NotifyIcon;
|
||||||
using Snap.Hutao.Factory.ContentDialog;
|
|
||||||
using Snap.Hutao.Service;
|
using Snap.Hutao.Service;
|
||||||
using Snap.Hutao.Win32;
|
using Snap.Hutao.Win32;
|
||||||
using Snap.Hutao.Win32.Foundation;
|
using Snap.Hutao.Win32.Foundation;
|
||||||
@@ -106,7 +105,7 @@ internal sealed class XamlWindowController
|
|||||||
{
|
{
|
||||||
if (!IsNotifyIconVisible())
|
if (!IsNotifyIconVisible())
|
||||||
{
|
{
|
||||||
new ToastContentBuilder()
|
new AppNotificationBuilder()
|
||||||
.AddText(SH.CoreWindowingNotifyIconPromotedHint)
|
.AddText(SH.CoreWindowingNotifyIconPromotedHint)
|
||||||
.Show();
|
.Show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Microsoft.Windows.AppNotifications;
|
||||||
|
using Microsoft.Windows.AppNotifications.Builder;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Extension;
|
||||||
|
|
||||||
|
internal static class AppNotificationBuilderExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Build and show the notification
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="builder">this</param>
|
||||||
|
/// <param name="manager">Defaults to <see cref="AppNotificationManager.Default"/></param>
|
||||||
|
public static void Show(this AppNotificationBuilder builder, AppNotificationManager? manager = default)
|
||||||
|
{
|
||||||
|
(manager ?? AppNotificationManager.Default).Show(builder.BuildNotification());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,19 @@ internal sealed partial class ContentDialogFactory : IContentDialogFactory
|
|||||||
private readonly ConcurrentQueue<Func<Task>> dialogQueue = [];
|
private readonly ConcurrentQueue<Func<Task>> dialogQueue = [];
|
||||||
private bool isDialogShowing;
|
private bool isDialogShowing;
|
||||||
|
|
||||||
|
public bool IsDialogShowing
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (currentWindowReference.Window is not { } window)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isDialogShowing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async ValueTask<ContentDialogResult> CreateForConfirmAsync(string title, string content)
|
public async ValueTask<ContentDialogResult> CreateForConfirmAsync(string title, string content)
|
||||||
{
|
{
|
||||||
@@ -115,7 +128,7 @@ internal sealed partial class ContentDialogFactory : IContentDialogFactory
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
await ShowNextDialog().ConfigureAwait(false);
|
ShowNextDialog().SafeForget();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ namespace Snap.Hutao.Factory.ContentDialog;
|
|||||||
[HighQuality]
|
[HighQuality]
|
||||||
internal interface IContentDialogFactory
|
internal interface IContentDialogFactory
|
||||||
{
|
{
|
||||||
|
bool IsDialogShowing { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步确认
|
/// 异步确认
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
654
src/Snap.Hutao/Snap.Hutao/Migrations/20240616104646_UidProfilePicture.Designer.cs
generated
Normal file
654
src/Snap.Hutao/Snap.Hutao/Migrations/20240616104646_UidProfilePicture.Designer.cs
generated
Normal file
@@ -0,0 +1,654 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Snap.Hutao.Model.Entity.Database;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20240616104646_UidProfilePicture")]
|
||||||
|
partial class UidProfilePicture
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.Achievement", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArchiveId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("Current")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("Id")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Time")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("ArchiveId");
|
||||||
|
|
||||||
|
b.ToTable("achievements");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.AchievementArchive", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsSelected")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("achievement_archives");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.AvatarInfo", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CalculatorRefreshTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("GameRecordRefreshTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Info")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("ShowcaseRefreshTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Uid")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("avatar_infos");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.CultivateEntry", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("Id")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProjectId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("ProjectId");
|
||||||
|
|
||||||
|
b.ToTable("cultivate_entries");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.CultivateEntryLevelInformation", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("AvatarLevelFrom")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("AvatarLevelTo")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("EntryId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("SkillALevelFrom")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("SkillALevelTo")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("SkillELevelFrom")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("SkillELevelTo")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("SkillQLevelFrom")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("SkillQLevelTo")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("WeaponLevelFrom")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("WeaponLevelTo")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("EntryId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("cultivate_entry_level_informations");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.CultivateItem", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("Count")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("EntryId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsFinished")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("ItemId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("EntryId");
|
||||||
|
|
||||||
|
b.ToTable("cultivate_items");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.CultivateProject", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("AttachedUid")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsSelected")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("cultivate_projects");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.DailyNoteEntry", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("DailyNote")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("DailyTaskNotify")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("DailyTaskNotifySuppressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("ExpeditionNotify")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("ExpeditionNotifySuppressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("HomeCoinNotifySuppressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("HomeCoinNotifyThreshold")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("RefreshTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("ResinNotifySuppressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ResinNotifyThreshold")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("TransformerNotify")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("TransformerNotifySuppressed")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Uid")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<Guid>("UserId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("daily_notes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.GachaArchive", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("IsSelected")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Uid")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("gacha_archives");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.GachaItem", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArchiveId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("GachaType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("ItemId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("QueryType")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Time")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("ArchiveId");
|
||||||
|
|
||||||
|
b.ToTable("gacha_items");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.GameAccount", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("AttachUid")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Index")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("MihoyoSDK")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("game_accounts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.InventoryItem", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("Count")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("ItemId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProjectId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("ProjectId");
|
||||||
|
|
||||||
|
b.ToTable("inventory_items");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.InventoryReliquary", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("AppendPropIdList")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("ItemId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Level")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("MainPropId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProjectId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("ProjectId");
|
||||||
|
|
||||||
|
b.ToTable("inventory_reliquaries");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.InventoryWeapon", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("ItemId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("Level")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProjectId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("PromoteLevel")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.HasIndex("ProjectId");
|
||||||
|
|
||||||
|
b.ToTable("inventory_weapons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.ObjectCacheEntry", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("ExpireTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Key");
|
||||||
|
|
||||||
|
b.ToTable("object_cache");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.SettingEntry", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("Key");
|
||||||
|
|
||||||
|
b.ToTable("settings");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.SpiralAbyssEntry", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("ScheduleId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("SpiralAbyss")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Uid")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("spiral_abysses");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.UidProfilePicture", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("AvatarId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("CostumeId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("ProfilePictureId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("RefreshTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Uid")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("uid_profile_pictures");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.User", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Aid")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("CookieToken")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CookieTokenLastUpdateTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Fingerprint")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("FingerprintLastUpdateTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Index")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("IsOversea")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("IsSelected")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("LToken")
|
||||||
|
.HasColumnType("TEXT")
|
||||||
|
.HasColumnName("Ltoken");
|
||||||
|
|
||||||
|
b.Property<string>("Mid")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("PreferredUid")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("SToken")
|
||||||
|
.HasColumnType("TEXT")
|
||||||
|
.HasColumnName("Stoken");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("users");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.Achievement", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.AchievementArchive", "Archive")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ArchiveId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Archive");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.CultivateEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.CultivateProject", "Project")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Project");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.CultivateEntryLevelInformation", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.CultivateEntry", "Entry")
|
||||||
|
.WithOne("LevelInformation")
|
||||||
|
.HasForeignKey("Snap.Hutao.Model.Entity.CultivateEntryLevelInformation", "EntryId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Entry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.CultivateItem", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.CultivateEntry", "Entry")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("EntryId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Entry");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.DailyNoteEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.GachaItem", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.GachaArchive", "Archive")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ArchiveId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Archive");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.InventoryItem", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.CultivateProject", "Project")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Project");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.InventoryReliquary", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.CultivateProject", "Project")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Project");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.InventoryWeapon", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Snap.Hutao.Model.Entity.CultivateProject", "Project")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProjectId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Project");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.CultivateEntry", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("LevelInformation");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class UidProfilePicture : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "uid_profile_pictures",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
InnerId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||||
|
Uid = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
|
ProfilePictureId = table.Column<uint>(type: "INTEGER", nullable: false),
|
||||||
|
AvatarId = table.Column<uint>(type: "INTEGER", nullable: false),
|
||||||
|
CostumeId = table.Column<uint>(type: "INTEGER", nullable: false),
|
||||||
|
RefreshTime = table.Column<DateTimeOffset>(type: "TEXT", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_uid_profile_pictures", x => x.InnerId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "uid_profile_pictures");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ namespace Snap.Hutao.Migrations
|
|||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
|
modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
|
||||||
|
|
||||||
modelBuilder.Entity("Snap.Hutao.Model.Entity.Achievement", b =>
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.Achievement", b =>
|
||||||
{
|
{
|
||||||
@@ -466,6 +466,33 @@ namespace Snap.Hutao.Migrations
|
|||||||
b.ToTable("spiral_abysses");
|
b.ToTable("spiral_abysses");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.UidProfilePicture", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("InnerId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<uint>("AvatarId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("CostumeId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<uint>("ProfilePictureId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("RefreshTime")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Uid")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("InnerId");
|
||||||
|
|
||||||
|
b.ToTable("uid_profile_pictures");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Snap.Hutao.Model.Entity.User", b =>
|
modelBuilder.Entity("Snap.Hutao.Model.Entity.User", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("InnerId")
|
b.Property<Guid>("InnerId")
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ internal sealed class AppDbContext : DbContext
|
|||||||
|
|
||||||
public DbSet<SpiralAbyssEntry> SpiralAbysses { get; set; } = default!;
|
public DbSet<SpiralAbyssEntry> SpiralAbysses { get; set; } = default!;
|
||||||
|
|
||||||
|
public DbSet<UidProfilePicture> UidProfilePictures { get; set; } = default!;
|
||||||
|
|
||||||
public static AppDbContext Create(IServiceProvider serviceProvider, string sqlConnectionString)
|
public static AppDbContext Create(IServiceProvider serviceProvider, string sqlConnectionString)
|
||||||
{
|
{
|
||||||
DbContextOptions<AppDbContext> options = new DbContextOptionsBuilder<AppDbContext>()
|
DbContextOptions<AppDbContext> options = new DbContextOptionsBuilder<AppDbContext>()
|
||||||
|
|||||||
41
src/Snap.Hutao/Snap.Hutao/Model/Entity/UidProfilePicture.cs
Normal file
41
src/Snap.Hutao/Snap.Hutao/Model/Entity/UidProfilePicture.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Core.Abstraction;
|
||||||
|
using Snap.Hutao.Web.Enka.Model;
|
||||||
|
using Snap.Hutao.Web.Hoyolab;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Model.Entity;
|
||||||
|
|
||||||
|
[Table("uid_profile_pictures")]
|
||||||
|
internal sealed class UidProfilePicture : IMappingFrom<UidProfilePicture, PlayerUid, ProfilePicture>
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public Guid InnerId { get; set; }
|
||||||
|
|
||||||
|
public string Uid { get; set; } = default!;
|
||||||
|
|
||||||
|
public uint ProfilePictureId { get; set; }
|
||||||
|
|
||||||
|
public uint AvatarId { get; set; }
|
||||||
|
|
||||||
|
public uint CostumeId { get; set; }
|
||||||
|
|
||||||
|
public DateTimeOffset RefreshTime { get; set; }
|
||||||
|
|
||||||
|
[SuppressMessage("", "SH002")]
|
||||||
|
public static UidProfilePicture From(PlayerUid uid, ProfilePicture profilePicture)
|
||||||
|
{
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Uid = uid.ToString(),
|
||||||
|
ProfilePictureId = profilePicture.Id,
|
||||||
|
AvatarId = profilePicture.AvatarId,
|
||||||
|
CostumeId = profilePicture.CostumeId,
|
||||||
|
RefreshTime = DateTimeOffset.Now,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Control;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Model.Metadata.Converter;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 玩家头像转换器
|
||||||
|
/// </summary>
|
||||||
|
[HighQuality]
|
||||||
|
internal sealed class AvatarIconCircleConverter : ValueConverter<string, Uri>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 名称转Uri
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">名称</param>
|
||||||
|
/// <returns>链接</returns>
|
||||||
|
public static Uri IconNameToUri(string name)
|
||||||
|
{
|
||||||
|
return Web.HutaoEndpoints.StaticRaw("AvatarIconCircle", $"{name}.png").ToUri();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override Uri Convert(string from)
|
||||||
|
{
|
||||||
|
return IconNameToUri(from);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
</desktop:Extension>
|
</desktop:Extension>
|
||||||
<com:Extension Category="windows.comServer">
|
<com:Extension Category="windows.comServer">
|
||||||
<com:ComServer>
|
<com:ComServer>
|
||||||
<com:ExeServer Executable="Snap.Hutao.exe" Arguments="-ToastActivated" DisplayName="Snap Hutao Toast Activator">
|
<com:ExeServer Executable="Snap.Hutao.exe" Arguments="----AppNotificationActivated:" DisplayName="Snap Hutao Toast Activator">
|
||||||
<com:Class Id="5760EC4D-F7E8-4666-A965-9886D7DFFE7D" DisplayName="Snap Hutao Toast Activator"/>
|
<com:Class Id="5760EC4D-F7E8-4666-A965-9886D7DFFE7D" DisplayName="Snap Hutao Toast Activator"/>
|
||||||
</com:ExeServer>
|
</com:ExeServer>
|
||||||
</com:ComServer>
|
</com:ComServer>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
</desktop:Extension>
|
</desktop:Extension>
|
||||||
<com:Extension Category="windows.comServer">
|
<com:Extension Category="windows.comServer">
|
||||||
<com:ComServer>
|
<com:ComServer>
|
||||||
<com:ExeServer Executable="Snap.Hutao.exe" Arguments="-ToastActivated" DisplayName="Snap Hutao Dev Toast Activator">
|
<com:ExeServer Executable="Snap.Hutao.exe" Arguments="----AppNotificationActivated:" DisplayName="Snap Hutao Toast Activator">
|
||||||
<com:Class Id="F32B561D-752E-472B-A22C-85824D421E1A" DisplayName="Snap Hutao Dev Toast Activator"/>
|
<com:Class Id="F32B561D-752E-472B-A22C-85824D421E1A" DisplayName="Snap Hutao Dev Toast Activator"/>
|
||||||
</com:ExeServer>
|
</com:ExeServer>
|
||||||
</com:ComServer>
|
</com:ComServer>
|
||||||
|
|||||||
@@ -1,7 +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 CommunityToolkit.WinUI.Notifications;
|
using Microsoft.Windows.AppNotifications;
|
||||||
using Snap.Hutao.Core;
|
using Snap.Hutao.Core;
|
||||||
using Snap.Hutao.Core.LifeCycle;
|
using Snap.Hutao.Core.LifeCycle;
|
||||||
using Snap.Hutao.Model.Entity;
|
using Snap.Hutao.Model.Entity;
|
||||||
@@ -20,7 +20,6 @@ namespace Snap.Hutao.Service.DailyNote;
|
|||||||
[Injection(InjectAs.Singleton)]
|
[Injection(InjectAs.Singleton)]
|
||||||
internal sealed partial class DailyNoteNotificationOperation
|
internal sealed partial class DailyNoteNotificationOperation
|
||||||
{
|
{
|
||||||
private const string ToastHeaderIdArgument = "DAILYNOTE";
|
|
||||||
private const string ToastAttributionUnknown = "Unknown";
|
private const string ToastAttributionUnknown = "Unknown";
|
||||||
|
|
||||||
private readonly ITaskContext taskContext;
|
private readonly ITaskContext taskContext;
|
||||||
@@ -52,57 +51,57 @@ internal sealed partial class DailyNoteNotificationOperation
|
|||||||
? entry.UserGameRole.ToString()
|
? entry.UserGameRole.ToString()
|
||||||
: await GetUserUidAsync(entry).ConfigureAwait(false);
|
: await GetUserUidAsync(entry).ConfigureAwait(false);
|
||||||
|
|
||||||
ToastContentBuilder builder = new ToastContentBuilder()
|
string reminder = options.IsReminderNotification ? @"scenario=""reminder""" : string.Empty;
|
||||||
.AddHeader(ToastHeaderIdArgument, SH.ServiceDailyNoteNotifierTitle, ToastHeaderIdArgument)
|
string content;
|
||||||
.AddAttributionText(attribution)
|
|
||||||
.AddButton(new ToastButton()
|
|
||||||
.SetContent(SH.ServiceDailyNoteNotifierActionLaunchGameButton)
|
|
||||||
.AddArgument(AppActivation.Action, AppActivation.LaunchGame)
|
|
||||||
.AddArgument(AppActivation.Uid, entry.Uid))
|
|
||||||
.AddButton(new ToastButtonDismiss(SH.ServiceDailyNoteNotifierActionLaunchGameDismiss));
|
|
||||||
|
|
||||||
if (options.IsReminderNotification)
|
|
||||||
{
|
|
||||||
builder.SetToastScenario(ToastScenario.Reminder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notifyInfos.Count > 2)
|
if (notifyInfos.Count > 2)
|
||||||
{
|
{
|
||||||
builder.AddText(SH.ServiceDailyNoteNotifierMultiValueReached);
|
string adaptiveSubgroups = string.Join(string.Empty, notifyInfos.Select(info => $"""
|
||||||
|
<subgroup>
|
||||||
|
<text hint-align="center">{info.AdaptiveHint}</text>
|
||||||
|
<text hint-style="captionSubtle" hint-align="center">{info.Title}</text>
|
||||||
|
</subgroup>
|
||||||
|
"""));
|
||||||
|
|
||||||
// Desktop and Mobile started supporting adaptive toasts in API contract 3 (Anniversary Update)
|
content = $"""
|
||||||
if (UniversalApiContract.IsPresent(WindowsVersion.Windows10AnniversaryUpdate))
|
<text>{SH.ServiceDailyNoteNotifierMultiValueReached}</text>
|
||||||
{
|
<group>
|
||||||
AdaptiveGroup group = new();
|
{adaptiveSubgroups}
|
||||||
foreach (DailyNoteNotifyInfo info in notifyInfos)
|
</group>
|
||||||
{
|
""";
|
||||||
AdaptiveSubgroup subgroup = new()
|
|
||||||
{
|
|
||||||
HintWeight = 1,
|
|
||||||
Children =
|
|
||||||
{
|
|
||||||
// new AdaptiveImage() { Source = info.AdaptiveIcon, HintRemoveMargin = true, },
|
|
||||||
new AdaptiveText() { Text = info.AdaptiveHint, HintAlign = AdaptiveTextAlign.Center, },
|
|
||||||
new AdaptiveText() { Text = info.Title, HintAlign = AdaptiveTextAlign.Center, HintStyle = AdaptiveTextStyle.CaptionSubtle, },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
group.Children.Add(subgroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.AddVisualChild(group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (DailyNoteNotifyInfo info in notifyInfos)
|
content = string.Join(string.Empty, notifyInfos.Select(info => $"""
|
||||||
{
|
<text>{info.Hint}</text>
|
||||||
builder.AddText(info.Hint);
|
"""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string rawXml = $"""
|
||||||
|
<toast {reminder}>
|
||||||
|
<header title="{SH.ServiceDailyNoteNotifierTitle}" id="DAILYNOTE" arguments="DAILYNOTE"/>
|
||||||
|
|
||||||
|
<visual>
|
||||||
|
<binding template="ToastGeneric">
|
||||||
|
{content}
|
||||||
|
<text placement="attribution">{attribution}</text>
|
||||||
|
</binding>
|
||||||
|
</visual>
|
||||||
|
<actions>
|
||||||
|
<action activationType="background" content="{SH.ServiceDailyNoteNotifierActionLaunchGameButton}" arguments="{AppActivation.Action}={AppActivation.LaunchGame};{AppActivation.Uid}={entry.Uid}"/>
|
||||||
|
<action activationType="system" content="{SH.ServiceDailyNoteNotifierActionLaunchGameDismiss}" arguments="dismiss"/>
|
||||||
|
</actions>
|
||||||
|
</toast>
|
||||||
|
""";
|
||||||
|
AppNotification notification = new(rawXml);
|
||||||
|
|
||||||
|
if (options.IsSilentWhenPlayingGame && gameService.IsGameRunning())
|
||||||
|
{
|
||||||
|
notification.SuppressDisplay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
await taskContext.SwitchToMainThreadAsync();
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
builder.Show(toast => toast.SuppressPopup = ShouldSuppressPopup(options));
|
AppNotificationManager.Default.Show(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ShouldSuppressPopup(DailyNoteOptions options)
|
private bool ShouldSuppressPopup(DailyNoteOptions options)
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ internal class LaunchScheme : IEquatable<ChannelOptions>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int LauncherId { get; private protected set; }
|
public int LauncherId { get; private protected set; }
|
||||||
|
|
||||||
|
public string HoyoPlayLauncherId { get; private protected set; } = default!;
|
||||||
|
|
||||||
|
public string HoyoPlayGameId { get; private protected set; } = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// API Key
|
/// API Key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -9,11 +9,15 @@ internal sealed class LaunchSchemeBilibili : LaunchScheme
|
|||||||
{
|
{
|
||||||
private const int SdkStaticLauncherBilibiliId = 17;
|
private const int SdkStaticLauncherBilibiliId = 17;
|
||||||
private const string SdkStaticLauncherBilibiliKey = "KAtdSsoQ";
|
private const string SdkStaticLauncherBilibiliKey = "KAtdSsoQ";
|
||||||
|
private const string HoyoPlayLauncherBilibiliId = "umfgRO5gh5";
|
||||||
|
private const string HoyoPlayGameBilibiliId = "T2S0Gz4Dr2";
|
||||||
|
|
||||||
public LaunchSchemeBilibili(SubChannelType subChannel, bool isNotCompatOnly = true)
|
public LaunchSchemeBilibili(SubChannelType subChannel, bool isNotCompatOnly = true)
|
||||||
{
|
{
|
||||||
LauncherId = SdkStaticLauncherBilibiliId;
|
LauncherId = SdkStaticLauncherBilibiliId;
|
||||||
Key = SdkStaticLauncherBilibiliKey;
|
Key = SdkStaticLauncherBilibiliKey;
|
||||||
|
HoyoPlayLauncherId = HoyoPlayLauncherBilibiliId;
|
||||||
|
HoyoPlayGameId = HoyoPlayGameBilibiliId;
|
||||||
Channel = ChannelType.Bili;
|
Channel = ChannelType.Bili;
|
||||||
SubChannel = subChannel;
|
SubChannel = subChannel;
|
||||||
IsOversea = false;
|
IsOversea = false;
|
||||||
|
|||||||
@@ -9,11 +9,15 @@ internal sealed class LaunchSchemeChinese : LaunchScheme
|
|||||||
{
|
{
|
||||||
private const int SdkStaticLauncherChineseId = 18;
|
private const int SdkStaticLauncherChineseId = 18;
|
||||||
private const string SdkStaticLauncherChineseKey = "eYd89JmJ";
|
private const string SdkStaticLauncherChineseKey = "eYd89JmJ";
|
||||||
|
private const string HoyoPlayLauncherChineseId = "jGHBHlcOq1";
|
||||||
|
private const string HoyoPlayGameChineseId = "1Z8W5NHUQb";
|
||||||
|
|
||||||
public LaunchSchemeChinese(ChannelType channel, SubChannelType subChannel, bool isNotCompatOnly = true)
|
public LaunchSchemeChinese(ChannelType channel, SubChannelType subChannel, bool isNotCompatOnly = true)
|
||||||
{
|
{
|
||||||
LauncherId = SdkStaticLauncherChineseId;
|
LauncherId = SdkStaticLauncherChineseId;
|
||||||
Key = SdkStaticLauncherChineseKey;
|
Key = SdkStaticLauncherChineseKey;
|
||||||
|
HoyoPlayLauncherId = HoyoPlayLauncherChineseId;
|
||||||
|
HoyoPlayGameId = HoyoPlayGameChineseId;
|
||||||
Channel = channel;
|
Channel = channel;
|
||||||
SubChannel = subChannel;
|
SubChannel = subChannel;
|
||||||
IsOversea = false;
|
IsOversea = false;
|
||||||
|
|||||||
@@ -9,11 +9,15 @@ internal sealed class LaunchSchemeOversea : LaunchScheme
|
|||||||
{
|
{
|
||||||
private const int SdkStaticLauncherOverseaId = 10;
|
private const int SdkStaticLauncherOverseaId = 10;
|
||||||
private const string SdkStaticLauncherOverseaKey = "gcStgarh";
|
private const string SdkStaticLauncherOverseaKey = "gcStgarh";
|
||||||
|
private const string HoyoPlayLauncherOverseaId = "VYTpXlbWo8";
|
||||||
|
private const string HoyoPlayGameOverseaId = "gopR6Cufr3";
|
||||||
|
|
||||||
public LaunchSchemeOversea(ChannelType channel, SubChannelType subChannel, bool isNotCompatOnly = true)
|
public LaunchSchemeOversea(ChannelType channel, SubChannelType subChannel, bool isNotCompatOnly = true)
|
||||||
{
|
{
|
||||||
LauncherId = SdkStaticLauncherOverseaId;
|
LauncherId = SdkStaticLauncherOverseaId;
|
||||||
Key = SdkStaticLauncherOverseaKey;
|
Key = SdkStaticLauncherOverseaKey;
|
||||||
|
HoyoPlayLauncherId = HoyoPlayLauncherOverseaId;
|
||||||
|
HoyoPlayGameId = HoyoPlayGameOverseaId;
|
||||||
Channel = channel;
|
Channel = channel;
|
||||||
SubChannel = subChannel;
|
SubChannel = subChannel;
|
||||||
IsOversea = true;
|
IsOversea = true;
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ internal sealed partial class DailyNoteRefreshJobScheduler : IJobScheduler
|
|||||||
|
|
||||||
ITrigger dailyNoteTrigger = TriggerBuilder.Create()
|
ITrigger dailyNoteTrigger = TriggerBuilder.Create()
|
||||||
.WithIdentity(JobIdentity.DailyNoteRefreshTriggerName, JobIdentity.DailyNoteGroupName)
|
.WithIdentity(JobIdentity.DailyNoteRefreshTriggerName, JobIdentity.DailyNoteGroupName)
|
||||||
.StartNow()
|
|
||||||
.WithSimpleSchedule(builder => builder.WithIntervalInSeconds(interval).RepeatForever())
|
.WithSimpleSchedule(builder => builder.WithIntervalInSeconds(interval).RepeatForever())
|
||||||
|
.StartAt(DateTimeOffset.Now.AddSeconds(interval))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
await scheduler.ScheduleJob(dailyNoteJob, dailyNoteTrigger).ConfigureAwait(false);
|
await scheduler.ScheduleJob(dailyNoteJob, dailyNoteTrigger).ConfigureAwait(false);
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Model.Metadata.Avatar;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Service.Metadata.ContextAbstraction;
|
||||||
|
|
||||||
|
internal interface IMetadataListProfilePictureSource
|
||||||
|
{
|
||||||
|
public List<ProfilePicture> ProfilePictures { get; set; }
|
||||||
|
}
|
||||||
@@ -38,6 +38,11 @@ internal static class MetadataServiceContextExtension
|
|||||||
listMaterialSource.Materials = await metadataService.GetMaterialListAsync(token).ConfigureAwait(false);
|
listMaterialSource.Materials = await metadataService.GetMaterialListAsync(token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context is IMetadataListProfilePictureSource dictionaryIdProfilePictureSource)
|
||||||
|
{
|
||||||
|
dictionaryIdProfilePictureSource.ProfilePictures = await metadataService.GetProfilePictureListAsync(token).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (context is IMetadataListReliquaryMainAffixLevelSource listReliquaryMainAffixLevelSource)
|
if (context is IMetadataListReliquaryMainAffixLevelSource listReliquaryMainAffixLevelSource)
|
||||||
{
|
{
|
||||||
listReliquaryMainAffixLevelSource.ReliquaryMainAffixLevels = await metadataService.GetReliquaryMainAffixLevelListAsync(token).ConfigureAwait(false);
|
listReliquaryMainAffixLevelSource.ReliquaryMainAffixLevels = await metadataService.GetReliquaryMainAffixLevelListAsync(token).ConfigureAwait(false);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ internal static class MetadataFileNames
|
|||||||
public const string FileNameMaterial = "Material";
|
public const string FileNameMaterial = "Material";
|
||||||
public const string FileNameMonster = "Monster";
|
public const string FileNameMonster = "Monster";
|
||||||
public const string FileNameMonsterCurve = "MonsterCurve";
|
public const string FileNameMonsterCurve = "MonsterCurve";
|
||||||
|
public const string FileNameProfilePicture = "ProfilePicture";
|
||||||
public const string FileNameReliquary = "Reliquary";
|
public const string FileNameReliquary = "Reliquary";
|
||||||
public const string FileNameReliquaryAffixWeight = "ReliquaryAffixWeight";
|
public const string FileNameReliquaryAffixWeight = "ReliquaryAffixWeight";
|
||||||
public const string FileNameReliquaryMainAffix = "ReliquaryMainAffix";
|
public const string FileNameReliquaryMainAffix = "ReliquaryMainAffix";
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ internal static class MetadataServiceListExtension
|
|||||||
return metadataService.FromCacheOrFileAsync<List<GrowCurve>>(FileNameMonsterCurve, token);
|
return metadataService.FromCacheOrFileAsync<List<GrowCurve>>(FileNameMonsterCurve, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ValueTask<List<ProfilePicture>> GetProfilePictureListAsync(this IMetadataService metadataService, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
return metadataService.FromCacheOrFileAsync<List<ProfilePicture>>(FileNameProfilePicture, token);
|
||||||
|
}
|
||||||
|
|
||||||
public static ValueTask<List<Reliquary>> GetReliquaryListAsync(this IMetadataService metadataService, CancellationToken token = default)
|
public static ValueTask<List<Reliquary>> GetReliquaryListAsync(this IMetadataService metadataService, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
return metadataService.FromCacheOrFileAsync<List<Reliquary>>(FileNameReliquary, token);
|
return metadataService.FromCacheOrFileAsync<List<Reliquary>>(FileNameReliquary, token);
|
||||||
|
|||||||
@@ -1,7 +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 CommunityToolkit.WinUI.Notifications;
|
using Microsoft.Windows.AppNotifications;
|
||||||
|
|
||||||
namespace Snap.Hutao.Service.Notification;
|
namespace Snap.Hutao.Service.Notification;
|
||||||
|
|
||||||
@@ -16,7 +16,8 @@ internal sealed class ToastNotificationLifeTime : IToastNotificationLifeTime
|
|||||||
// 用于在程序退出时尝试清除所有的系统通知
|
// 用于在程序退出时尝试清除所有的系统通知
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ToastNotificationManagerCompat.History.Clear();
|
AppNotificationManager.Default.RemoveAllAsync().AsTask().GetAwaiter().GetResult();
|
||||||
|
AppNotificationManager.Default.Unregister();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Model.Entity;
|
||||||
|
using Snap.Hutao.Web.Hoyolab.Takumi.Binding;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Service.User;
|
||||||
|
|
||||||
|
internal interface IProfilePictureService
|
||||||
|
{
|
||||||
|
ValueTask TryInitializeAsync(ViewModel.User.User user, CancellationToken token = default(CancellationToken));
|
||||||
|
|
||||||
|
ValueTask RefreshUserGameRoleAsync(UserGameRole userGameRole, CancellationToken token = default(CancellationToken));
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Model.Entity;
|
||||||
|
using Snap.Hutao.Service.Abstraction;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Service.User;
|
||||||
|
|
||||||
|
internal interface IUidProfilePictureDbService : IAppDbService<UidProfilePicture>
|
||||||
|
{
|
||||||
|
ValueTask<UidProfilePicture?> SingleUidProfilePictureOrDefaultByUidAsync(string uid, CancellationToken token = default);
|
||||||
|
|
||||||
|
ValueTask UpdateUidProfilePictureAsync(UidProfilePicture profilePicture, CancellationToken token = default);
|
||||||
|
|
||||||
|
ValueTask DeleteUidProfilePictureByUidAsync(string uid, CancellationToken token = default);
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
// 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.Takumi.Binding;
|
||||||
|
|
||||||
namespace Snap.Hutao.Service.User;
|
namespace Snap.Hutao.Service.User;
|
||||||
|
|
||||||
internal interface IUserInitializationService
|
internal interface IUserInitializationService
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Service.Metadata.ContextAbstraction;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Service.User;
|
||||||
|
|
||||||
|
internal interface IUserMetadataContext : IMetadataContext,
|
||||||
|
IMetadataListProfilePictureSource;
|
||||||
@@ -53,4 +53,6 @@ internal interface IUserService
|
|||||||
/// <param name="user">待移除的用户</param>
|
/// <param name="user">待移除的用户</param>
|
||||||
/// <returns>任务</returns>
|
/// <returns>任务</returns>
|
||||||
ValueTask RemoveUserAsync(BindingUser user);
|
ValueTask RemoveUserAsync(BindingUser user);
|
||||||
|
|
||||||
|
ValueTask RefreshProfilePictureAsync(UserGameRole userGameRole);
|
||||||
}
|
}
|
||||||
109
src/Snap.Hutao/Snap.Hutao/Service/User/ProfilePictureService.cs
Normal file
109
src/Snap.Hutao/Snap.Hutao/Service/User/ProfilePictureService.cs
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Model.Entity;
|
||||||
|
using Snap.Hutao.Model.Intrinsic;
|
||||||
|
using Snap.Hutao.Service.Metadata;
|
||||||
|
using Snap.Hutao.Service.Metadata.ContextAbstraction;
|
||||||
|
using Snap.Hutao.Web.Enka;
|
||||||
|
using Snap.Hutao.Web.Enka.Model;
|
||||||
|
using Snap.Hutao.Web.Hoyolab.Takumi.Binding;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Service.User;
|
||||||
|
|
||||||
|
[ConstructorGenerated]
|
||||||
|
[Injection(InjectAs.Singleton, typeof(IProfilePictureService))]
|
||||||
|
internal sealed partial class ProfilePictureService : IProfilePictureService
|
||||||
|
{
|
||||||
|
private readonly IUidProfilePictureDbService uidProfilePictureDbService;
|
||||||
|
private readonly IMetadataService metadataService;
|
||||||
|
private readonly IServiceProvider serviceProvider;
|
||||||
|
private readonly ITaskContext taskContext;
|
||||||
|
|
||||||
|
public async ValueTask TryInitializeAsync(ViewModel.User.User user, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
foreach (UserGameRole userGameRole in user.UserGameRoles)
|
||||||
|
{
|
||||||
|
if (await uidProfilePictureDbService.SingleUidProfilePictureOrDefaultByUidAsync(userGameRole.GameUid, token).ConfigureAwait(false) is { } profilePicture)
|
||||||
|
{
|
||||||
|
if (await TryUpdateUserGameRoleAsync(userGameRole, profilePicture, token).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force update
|
||||||
|
await RefreshUserGameRoleAsync(userGameRole, token: token).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask RefreshUserGameRoleAsync(UserGameRole userGameRole, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
EnkaResponse? enkaResponse;
|
||||||
|
using (IServiceScope scope = serviceProvider.CreateScope())
|
||||||
|
{
|
||||||
|
EnkaClient enkaClient = scope.ServiceProvider
|
||||||
|
.GetRequiredService<EnkaClient>();
|
||||||
|
|
||||||
|
enkaResponse = await enkaClient.GetForwardPlayerInfoAsync(userGameRole, token).ConfigureAwait(false)
|
||||||
|
?? await enkaClient.GetPlayerInfoAsync(userGameRole, token).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enkaResponse is { PlayerInfo: { } playerInfo })
|
||||||
|
{
|
||||||
|
UidProfilePicture profilePicture = UidProfilePicture.From(userGameRole, playerInfo.ProfilePicture);
|
||||||
|
|
||||||
|
await uidProfilePictureDbService.DeleteUidProfilePictureByUidAsync(userGameRole.GameUid, token).ConfigureAwait(false);
|
||||||
|
await uidProfilePictureDbService.UpdateUidProfilePictureAsync(profilePicture, token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
await TryUpdateUserGameRoleAsync(userGameRole, profilePicture, token).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async ValueTask<bool> TryUpdateUserGameRoleAsync(UserGameRole userGameRole, UidProfilePicture cache, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
if (cache.RefreshTime.AddDays(15) < DateTimeOffset.Now)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!await metadataService.InitializeAsync().ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserMetadataContext context = await metadataService.GetContextAsync<UserMetadataContext>(token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
|
|
||||||
|
// Most common to most rare
|
||||||
|
if (cache.ProfilePictureId is not 0U)
|
||||||
|
{
|
||||||
|
userGameRole.ProfilePictureIcon = context.ProfilePictures
|
||||||
|
.Single(p => p.Id == cache.ProfilePictureId)
|
||||||
|
.Icon;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cache.AvatarId is not 0U)
|
||||||
|
{
|
||||||
|
userGameRole.ProfilePictureIcon = context.ProfilePictures
|
||||||
|
.Single(p => p.UnlockType is ProfilePictureUnlockType.Avatar && p.UnlockParameter == cache.AvatarId)
|
||||||
|
.Icon;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cache.CostumeId is not 0U)
|
||||||
|
{
|
||||||
|
userGameRole.ProfilePictureIcon = context.ProfilePictures
|
||||||
|
.Single(p => p.UnlockType is ProfilePictureUnlockType.Costume && p.UnlockParameter == cache.CostumeId)
|
||||||
|
.Icon;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Snap.Hutao.Model.Entity;
|
||||||
|
using Snap.Hutao.Service.Abstraction;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Service.User;
|
||||||
|
|
||||||
|
[ConstructorGenerated]
|
||||||
|
[Injection(InjectAs.Singleton, typeof(IUidProfilePictureDbService))]
|
||||||
|
internal sealed partial class UidProfilePictureDbService : IUidProfilePictureDbService
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider serviceProvider;
|
||||||
|
|
||||||
|
public IServiceProvider ServiceProvider { get => serviceProvider; }
|
||||||
|
|
||||||
|
public ValueTask<UidProfilePicture?> SingleUidProfilePictureOrDefaultByUidAsync(string uid, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
return this.QueryAsync(query => query.SingleOrDefaultAsync(n => n.Uid == uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask UpdateUidProfilePictureAsync(UidProfilePicture profilePicture, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
await this.UpdateAsync(profilePicture, token).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask DeleteUidProfilePictureByUidAsync(string uid, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
await this.DeleteAsync(profilePicture => profilePicture.Uid == uid, token).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ namespace Snap.Hutao.Service.User;
|
|||||||
internal sealed partial class UserInitializationService : IUserInitializationService
|
internal sealed partial class UserInitializationService : IUserInitializationService
|
||||||
{
|
{
|
||||||
private readonly IUserFingerprintService userFingerprintService;
|
private readonly IUserFingerprintService userFingerprintService;
|
||||||
|
private readonly IProfilePictureService profilePictureService;
|
||||||
private readonly IServiceProvider serviceProvider;
|
private readonly IServiceProvider serviceProvider;
|
||||||
|
|
||||||
public async ValueTask<ViewModel.User.User> ResumeUserAsync(Model.Entity.User inner, CancellationToken token = default)
|
public async ValueTask<ViewModel.User.User> ResumeUserAsync(Model.Entity.User inner, CancellationToken token = default)
|
||||||
@@ -90,6 +91,7 @@ internal sealed partial class UserInitializationService : IUserInitializationSer
|
|||||||
}
|
}
|
||||||
|
|
||||||
await userFingerprintService.TryInitializeAsync(user, token).ConfigureAwait(false);
|
await userFingerprintService.TryInitializeAsync(user, token).ConfigureAwait(false);
|
||||||
|
await profilePictureService.TryInitializeAsync(user, token).ConfigureAwait(false);
|
||||||
|
|
||||||
return user.IsInitialized = true;
|
return user.IsInitialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Model.Metadata.Avatar;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Service.User;
|
||||||
|
|
||||||
|
internal class UserMetadataContext : IUserMetadataContext
|
||||||
|
{
|
||||||
|
public List<ProfilePicture> ProfilePictures { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ namespace Snap.Hutao.Service.User;
|
|||||||
[Injection(InjectAs.Singleton, typeof(IUserService))]
|
[Injection(InjectAs.Singleton, typeof(IUserService))]
|
||||||
internal sealed partial class UserService : IUserService, IUserServiceUnsafe
|
internal sealed partial class UserService : IUserService, IUserServiceUnsafe
|
||||||
{
|
{
|
||||||
|
private readonly IProfilePictureService profilePictureService;
|
||||||
private readonly IUserCollectionService userCollectionService;
|
private readonly IUserCollectionService userCollectionService;
|
||||||
private readonly IServiceProvider serviceProvider;
|
private readonly IServiceProvider serviceProvider;
|
||||||
private readonly IUserDbService userDbService;
|
private readonly IUserDbService userDbService;
|
||||||
@@ -121,4 +122,9 @@ internal sealed partial class UserService : IUserService, IUserServiceUnsafe
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ValueTask RefreshProfilePictureAsync(UserGameRole userGameRole)
|
||||||
|
{
|
||||||
|
await profilePictureService.RefreshUserGameRoleAsync(userGameRole).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +312,6 @@
|
|||||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.0.240109" />
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.Controls.TokenizingTextBox" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Controls.TokenizingTextBox" Version="8.0.240109" />
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.0.240109" />
|
<PackageReference Include="CommunityToolkit.WinUI.Media" Version="8.0.240109" />
|
||||||
<PackageReference Include="CommunityToolkit.WinUI.Notifications" Version="7.1.2" />
|
|
||||||
<PackageReference Include="Google.OrTools" Version="9.10.4067" />
|
<PackageReference Include="Google.OrTools" Version="9.10.4067" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.6">
|
||||||
|
|||||||
@@ -6,12 +6,13 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||||
xmlns:shwhshlr="using:Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource"
|
xmlns:shwhhpc="using:Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect"
|
||||||
|
xmlns:shwhhpcp="using:Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
d:DataContext="{d:DesignInstance shwhshlr:Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource.Package}"
|
d:DataContext="{d:DesignInstance shwhhpcp:Package}"
|
||||||
IsExpanded="True"
|
IsExpanded="True"
|
||||||
ItemsSource="{Binding VoicePacks}"
|
ItemsSource="{Binding AllPackages}"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<cwc:SettingsExpander.Resources>
|
<cwc:SettingsExpander.Resources>
|
||||||
@@ -24,7 +25,7 @@
|
|||||||
</cwc:SettingsExpander.Resources>
|
</cwc:SettingsExpander.Resources>
|
||||||
|
|
||||||
<cwc:SettingsExpander.ItemTemplate>
|
<cwc:SettingsExpander.ItemTemplate>
|
||||||
<DataTemplate x:DataType="shwhshlr:VoicePackage">
|
<DataTemplate x:DataType="shwhhpc:PackageSegment">
|
||||||
<cwc:SettingsCard
|
<cwc:SettingsCard
|
||||||
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
|
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
|
||||||
ActionIcon="{shcm:FontIcon Glyph={StaticResource FontIconContentCopy}}"
|
ActionIcon="{shcm:FontIcon Glyph={StaticResource FontIconContentCopy}}"
|
||||||
@@ -42,13 +43,13 @@
|
|||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
Text="{Binding PackageSize, Converter={StaticResource FileSizeToFriendlyStringConverter}}"/>
|
Text="{Binding Size, Converter={StaticResource FileSizeToFriendlyStringConverter}}"/>
|
||||||
<FontIcon FontSize="{StaticResource CaptionTextBlockFontSize}" Glyph="{StaticResource FontIconContentFolder}"/>
|
<FontIcon FontSize="{StaticResource CaptionTextBlockFontSize}" Glyph="{StaticResource FontIconContentFolder}"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Width="80"
|
Width="80"
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
Text="{Binding Size, Converter={StaticResource FileSizeToFriendlyStringConverter}}"/>
|
Text="{Binding DecompressedSize, Converter={StaticResource FileSizeToFriendlyStringConverter}}"/>
|
||||||
<FontIcon FontSize="{StaticResource CaptionTextBlockFontSize}" Glyph="{StaticResource FontIconContentAsteriskBadge12}"/>
|
<FontIcon FontSize="{StaticResource CaptionTextBlockFontSize}" Glyph="{StaticResource FontIconContentAsteriskBadge12}"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
@@ -60,45 +61,4 @@
|
|||||||
</cwc:SettingsCard>
|
</cwc:SettingsCard>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</cwc:SettingsExpander.ItemTemplate>
|
</cwc:SettingsExpander.ItemTemplate>
|
||||||
|
|
||||||
<cwc:SettingsExpander.ItemsHeader>
|
|
||||||
<cwc:SettingsCard
|
|
||||||
MinHeight="52"
|
|
||||||
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
|
|
||||||
ActionIcon="{shcm:FontIcon Glyph={StaticResource FontIconContentCopy}}"
|
|
||||||
Background="{ThemeResource InfoBarInformationalSeverityBackgroundBrush}"
|
|
||||||
BorderThickness="0"
|
|
||||||
Command="{Binding CopyPathCommand}"
|
|
||||||
CornerRadius="0"
|
|
||||||
Header="{Binding DisplayName}"
|
|
||||||
IsClickEnabled="True">
|
|
||||||
<cwc:SettingsCard.Description>
|
|
||||||
<StackPanel
|
|
||||||
Grid.Row="1"
|
|
||||||
Margin="0,4,0,0"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
<FontIcon FontSize="{StaticResource CaptionTextBlockFontSize}" Glyph="{StaticResource FontIconContentZipFolder}"/>
|
|
||||||
<TextBlock
|
|
||||||
Width="80"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
|
||||||
Text="{Binding PackageSize, Converter={StaticResource FileSizeToFriendlyStringConverter}}"/>
|
|
||||||
<FontIcon FontSize="{StaticResource CaptionTextBlockFontSize}" Glyph="{StaticResource FontIconContentFolder}"/>
|
|
||||||
<TextBlock
|
|
||||||
Width="80"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
|
||||||
Text="{Binding Size, Converter={StaticResource FileSizeToFriendlyStringConverter}}"/>
|
|
||||||
<FontIcon FontSize="{StaticResource CaptionTextBlockFontSize}" Glyph="{StaticResource FontIconContentAsteriskBadge12}"/>
|
|
||||||
<TextBlock
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
IsTextSelectionEnabled="True"
|
|
||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
|
||||||
Text="{Binding Md5}"/>
|
|
||||||
</StackPanel>
|
|
||||||
</cwc:SettingsCard.Description>
|
|
||||||
</cwc:SettingsCard>
|
|
||||||
</cwc:SettingsExpander.ItemsHeader>
|
|
||||||
|
|
||||||
</cwc:SettingsExpander>
|
</cwc:SettingsExpander>
|
||||||
|
|||||||
@@ -301,7 +301,7 @@
|
|||||||
<ScrollViewer>
|
<ScrollViewer>
|
||||||
<ItemsControl
|
<ItemsControl
|
||||||
Margin="0,0,-4,0"
|
Margin="0,0,-4,0"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Left"
|
||||||
ItemContainerTransitions="{StaticResource ListViewLikeThemeTransitions}"
|
ItemContainerTransitions="{StaticResource ListViewLikeThemeTransitions}"
|
||||||
ItemTemplate="{StaticResource DownloadSummaryTemplate}"
|
ItemTemplate="{StaticResource DownloadSummaryTemplate}"
|
||||||
ItemsPanel="{StaticResource WrapPanelSpacing0Template}"
|
ItemsPanel="{StaticResource WrapPanelSpacing0Template}"
|
||||||
|
|||||||
@@ -366,13 +366,13 @@
|
|||||||
</PivotItem>
|
</PivotItem>
|
||||||
<PivotItem Header="{shcm:ResourceString Name=ViewPageLaunchGameResourceHeader}">
|
<PivotItem Header="{shcm:ResourceString Name=ViewPageLaunchGameResourceHeader}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<ScrollViewer Visibility="{Binding GameResource, Converter={StaticResource EmptyObjectToBoolConverter}}">
|
<ScrollViewer Visibility="{Binding GamePackage, Converter={StaticResource EmptyObjectToBoolConverter}}">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Border Margin="16,16,16,0" cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
|
<Border Margin="16,16,16,0" cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
|
||||||
<Border Style="{ThemeResource AcrylicBorderCardStyle}">
|
<Border Style="{ThemeResource AcrylicBorderCardStyle}">
|
||||||
<shvc:LaunchGameResourceExpander
|
<shvc:LaunchGameResourceExpander
|
||||||
cw:Effects.Shadow="{ThemeResource CompatCardShadow}"
|
cw:Effects.Shadow="{ThemeResource CompatCardShadow}"
|
||||||
DataContext="{Binding GameResource.PreDownloadGame.Latest, Mode=OneWay}"
|
DataContext="{Binding GamePackage.PreDownload.Major, Mode=OneWay}"
|
||||||
Header="{shcm:ResourceString Name=ViewPageLaunchGameResourcePreDownloadHeader}"
|
Header="{shcm:ResourceString Name=ViewPageLaunchGameResourcePreDownloadHeader}"
|
||||||
IsEnabled="{Binding FallbackValue=False, Converter={StaticResource EmptyObjectToBoolConverter}}"
|
IsEnabled="{Binding FallbackValue=False, Converter={StaticResource EmptyObjectToBoolConverter}}"
|
||||||
IsExpanded="{Binding FallbackValue=False, Converter={StaticResource EmptyObjectToBoolConverter}, Mode=OneTime}"/>
|
IsExpanded="{Binding FallbackValue=False, Converter={StaticResource EmptyObjectToBoolConverter}, Mode=OneTime}"/>
|
||||||
@@ -382,22 +382,22 @@
|
|||||||
<ItemsControl
|
<ItemsControl
|
||||||
Margin="0,0,0,0"
|
Margin="0,0,0,0"
|
||||||
ItemTemplate="{StaticResource GameResourceTemplate}"
|
ItemTemplate="{StaticResource GameResourceTemplate}"
|
||||||
ItemsSource="{Binding GameResource.PreDownloadGame.Diffs, Mode=OneWay}"/>
|
ItemsSource="{Binding GamePackage.PreDownload.Patches, Mode=OneWay}"/>
|
||||||
<Border Margin="16,16,16,0" cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
|
<Border Margin="16,16,16,0" cw:Effects.Shadow="{ThemeResource CompatCardShadow}">
|
||||||
<Border Style="{ThemeResource AcrylicBorderCardStyle}">
|
<Border Style="{ThemeResource AcrylicBorderCardStyle}">
|
||||||
<shvc:LaunchGameResourceExpander
|
<shvc:LaunchGameResourceExpander
|
||||||
cw:Effects.Shadow="{ThemeResource CompatCardShadow}"
|
cw:Effects.Shadow="{ThemeResource CompatCardShadow}"
|
||||||
DataContext="{Binding GameResource.Game.Latest, Mode=OneWay}"
|
DataContext="{Binding GamePackage.Main.Major, Mode=OneWay}"
|
||||||
Header="{shcm:ResourceString Name=ViewPageLaunchGameResourceLatestHeader}"/>
|
Header="{shcm:ResourceString Name=ViewPageLaunchGameResourceLatestHeader}"/>
|
||||||
</Border>
|
</Border>
|
||||||
</Border>
|
</Border>
|
||||||
<ItemsControl
|
<ItemsControl
|
||||||
Margin="0,0,0,16"
|
Margin="0,0,0,16"
|
||||||
ItemTemplate="{StaticResource GameResourceTemplate}"
|
ItemTemplate="{StaticResource GameResourceTemplate}"
|
||||||
ItemsSource="{Binding GameResource.Game.Diffs, Mode=OneWay}"/>
|
ItemsSource="{Binding GamePackage.Main.Patches, Mode=OneWay}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
<shvc:LoadingView IsLoading="{Binding GameResource, Converter={StaticResource EmptyObjectToBoolRevertConverter}}"/>
|
<shvc:LoadingView IsLoading="{Binding GamePackage, Converter={StaticResource EmptyObjectToBoolRevertConverter}}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</PivotItem>
|
</PivotItem>
|
||||||
</Pivot>
|
</Pivot>
|
||||||
|
|||||||
@@ -19,7 +19,66 @@
|
|||||||
<shc:BindingProxy x:Key="ViewModelBindingProxy" DataContext="{Binding}"/>
|
<shc:BindingProxy x:Key="ViewModelBindingProxy" DataContext="{Binding}"/>
|
||||||
|
|
||||||
<DataTemplate x:Key="UserGameRoleTemplate">
|
<DataTemplate x:Key="UserGameRoleTemplate">
|
||||||
<StackPanel Padding="0,6">
|
<Grid Padding="0,12" Background="Transparent">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="auto"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<PersonPicture
|
||||||
|
Grid.Column="0"
|
||||||
|
Height="32"
|
||||||
|
Margin="2,0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Background="#FFDAB79B"
|
||||||
|
ProfilePicture="{Binding ProfilePictureIcon, Converter={StaticResource AvatarIconCircleConverter}}"/>
|
||||||
|
<Button
|
||||||
|
Grid.Column="0"
|
||||||
|
Width="32"
|
||||||
|
Height="32"
|
||||||
|
Margin="2,0"
|
||||||
|
Padding="0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderBrush="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
Command="{Binding RefreshProfilePictureCommand}"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
CornerRadius="{ThemeResource CornerRadiusAll16}">
|
||||||
|
<Button.Resources>
|
||||||
|
<Storyboard x:Key="ShowRefreshIcon">
|
||||||
|
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RefreshIcon" Storyboard.TargetProperty="Visibility">
|
||||||
|
<DiscreteObjectKeyFrame KeyTime="0">
|
||||||
|
<DiscreteObjectKeyFrame.Value>
|
||||||
|
<Visibility>Visible</Visibility>
|
||||||
|
</DiscreteObjectKeyFrame.Value>
|
||||||
|
</DiscreteObjectKeyFrame>
|
||||||
|
</ObjectAnimationUsingKeyFrames>
|
||||||
|
</Storyboard>
|
||||||
|
<Storyboard x:Key="HideRefreshIcon">
|
||||||
|
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="RefreshIcon" Storyboard.TargetProperty="Visibility">
|
||||||
|
<DiscreteObjectKeyFrame KeyTime="0">
|
||||||
|
<DiscreteObjectKeyFrame.Value>
|
||||||
|
<Visibility>Collapsed</Visibility>
|
||||||
|
</DiscreteObjectKeyFrame.Value>
|
||||||
|
</DiscreteObjectKeyFrame>
|
||||||
|
</ObjectAnimationUsingKeyFrames>
|
||||||
|
</Storyboard>
|
||||||
|
</Button.Resources>
|
||||||
|
<mxi:Interaction.Behaviors>
|
||||||
|
<mxic:EventTriggerBehavior EventName="PointerEntered">
|
||||||
|
<mxim:ControlStoryboardAction Storyboard="{StaticResource ShowRefreshIcon}"/>
|
||||||
|
</mxic:EventTriggerBehavior>
|
||||||
|
<mxic:EventTriggerBehavior EventName="PointerExited">
|
||||||
|
<mxim:ControlStoryboardAction Storyboard="{StaticResource HideRefreshIcon}"/>
|
||||||
|
</mxic:EventTriggerBehavior>
|
||||||
|
</mxi:Interaction.Behaviors>
|
||||||
|
<FontIcon
|
||||||
|
x:Name="RefreshIcon"
|
||||||
|
FontSize="12"
|
||||||
|
Glyph=""
|
||||||
|
Visibility="Collapsed"/>
|
||||||
|
</Button>
|
||||||
|
<StackPanel Grid.Column="1" Margin="12,0">
|
||||||
<TextBlock Text="{Binding Nickname}"/>
|
<TextBlock Text="{Binding Nickname}"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="0,2,0,0"
|
Margin="0,2,0,0"
|
||||||
@@ -27,6 +86,7 @@
|
|||||||
Style="{StaticResource CaptionTextBlockStyle}"
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
Text="{Binding Description}"/>
|
Text="{Binding Description}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<DataTemplate x:Key="UserTemplate">
|
<DataTemplate x:Key="UserTemplate">
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ using Snap.Hutao.Service.Game.PathAbstraction;
|
|||||||
using Snap.Hutao.Service.Game.Scheme;
|
using Snap.Hutao.Service.Game.Scheme;
|
||||||
using Snap.Hutao.Service.Notification;
|
using Snap.Hutao.Service.Notification;
|
||||||
using Snap.Hutao.Service.User;
|
using Snap.Hutao.Service.User;
|
||||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect;
|
||||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
@@ -39,7 +39,6 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
|||||||
private readonly IGameLocatorFactory gameLocatorFactory;
|
private readonly IGameLocatorFactory gameLocatorFactory;
|
||||||
private readonly LaunchGameShared launchGameShared;
|
private readonly LaunchGameShared launchGameShared;
|
||||||
private readonly IInfoBarService infoBarService;
|
private readonly IInfoBarService infoBarService;
|
||||||
private readonly ResourceClient resourceClient;
|
|
||||||
private readonly RuntimeOptions runtimeOptions;
|
private readonly RuntimeOptions runtimeOptions;
|
||||||
private readonly LaunchOptions launchOptions;
|
private readonly LaunchOptions launchOptions;
|
||||||
private readonly IUserService userService;
|
private readonly IUserService userService;
|
||||||
@@ -47,11 +46,12 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
|||||||
private readonly IGameServiceFacade gameService;
|
private readonly IGameServiceFacade gameService;
|
||||||
private readonly IMemoryCache memoryCache;
|
private readonly IMemoryCache memoryCache;
|
||||||
private readonly AppOptions appOptions;
|
private readonly AppOptions appOptions;
|
||||||
|
private readonly HoyoPlayClient hoyoPlayClient;
|
||||||
|
|
||||||
private LaunchScheme? selectedScheme;
|
private LaunchScheme? selectedScheme;
|
||||||
private AdvancedCollectionView<GameAccount>? gameAccountsView;
|
private AdvancedCollectionView<GameAccount>? gameAccountsView;
|
||||||
private GameAccount? selectedGameAccount;
|
private GameAccount? selectedGameAccount;
|
||||||
private GameResource? gameResource;
|
private GamePackage? gamePackage;
|
||||||
private bool gamePathSelectedAndValid;
|
private bool gamePathSelectedAndValid;
|
||||||
private ImmutableList<GamePathEntry> gamePathEntries;
|
private ImmutableList<GamePathEntry> gamePathEntries;
|
||||||
private GamePathEntry? selectedGamePathEntry;
|
private GamePathEntry? selectedGamePathEntry;
|
||||||
@@ -69,7 +69,7 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
|||||||
|
|
||||||
public List<LaunchScheme> KnownSchemes { get; } = KnownLaunchSchemes.Get();
|
public List<LaunchScheme> KnownSchemes { get; } = KnownLaunchSchemes.Get();
|
||||||
|
|
||||||
[AlsoAsyncSets(nameof(GameResource), nameof(GameAccountsView))]
|
[AlsoAsyncSets(nameof(GameAccountsView), nameof(GamePackage))]
|
||||||
public LaunchScheme? SelectedScheme
|
public LaunchScheme? SelectedScheme
|
||||||
{
|
{
|
||||||
get => selectedScheme;
|
get => selectedScheme;
|
||||||
@@ -80,7 +80,7 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
|||||||
|
|
||||||
public GameAccount? SelectedGameAccount { get => selectedGameAccount; set => SetProperty(ref selectedGameAccount, value); }
|
public GameAccount? SelectedGameAccount { get => selectedGameAccount; set => SetProperty(ref selectedGameAccount, value); }
|
||||||
|
|
||||||
public GameResource? GameResource { get => gameResource; set => SetProperty(ref gameResource, value); }
|
public GamePackage? GamePackage { get => gamePackage; set => SetProperty(ref gamePackage, value); }
|
||||||
|
|
||||||
public bool GamePathSelectedAndValid
|
public bool GamePathSelectedAndValid
|
||||||
{
|
{
|
||||||
@@ -301,10 +301,10 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
|||||||
SelectedGameAccount = default;
|
SelectedGameAccount = default;
|
||||||
|
|
||||||
await UpdateGameAccountsViewAsync().ConfigureAwait(false);
|
await UpdateGameAccountsViewAsync().ConfigureAwait(false);
|
||||||
UpdateGameResourceAsync(value).SafeForget();
|
UpdateGamePackageAsync(value).SafeForget();
|
||||||
}
|
}
|
||||||
|
|
||||||
async ValueTask UpdateGameResourceAsync(LaunchScheme? scheme)
|
async ValueTask UpdateGamePackageAsync(LaunchScheme? scheme)
|
||||||
{
|
{
|
||||||
if (scheme is null)
|
if (scheme is null)
|
||||||
{
|
{
|
||||||
@@ -312,14 +312,14 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
|||||||
}
|
}
|
||||||
|
|
||||||
await taskContext.SwitchToBackgroundAsync();
|
await taskContext.SwitchToBackgroundAsync();
|
||||||
Web.Response.Response<GameResource> response = await resourceClient
|
Web.Response.Response<GamePackages> response = await hoyoPlayClient
|
||||||
.GetResourceAsync(scheme)
|
.GetPackagesAsync(scheme)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (response.IsOk())
|
if (response.IsOk())
|
||||||
{
|
{
|
||||||
await taskContext.SwitchToMainThreadAsync();
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
GameResource = response.Data;
|
GamePackage = response.Data.Packages.Single();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ internal static class StaticResource
|
|||||||
{ "AchievementIcon", 0 },
|
{ "AchievementIcon", 0 },
|
||||||
{ "AvatarCard", 0 },
|
{ "AvatarCard", 0 },
|
||||||
{ "AvatarIcon", 0 },
|
{ "AvatarIcon", 0 },
|
||||||
|
{ "AvatarIconCircle", 0 },
|
||||||
{ "Bg", 0 },
|
{ "Bg", 0 },
|
||||||
{ "ChapterIcon", 0 },
|
{ "ChapterIcon", 0 },
|
||||||
{ "CodexMonster", 0 },
|
{ "CodexMonster", 0 },
|
||||||
@@ -50,6 +51,7 @@ internal static class StaticResource
|
|||||||
{ "AchievementIcon", 2 },
|
{ "AchievementIcon", 2 },
|
||||||
{ "AvatarCard", 2 },
|
{ "AvatarCard", 2 },
|
||||||
{ "AvatarIcon", 5 },
|
{ "AvatarIcon", 5 },
|
||||||
|
{ "AvatarIconCircle", 1 },
|
||||||
{ "Bg", 3 },
|
{ "Bg", 3 },
|
||||||
{ "ChapterIcon", 3 },
|
{ "ChapterIcon", 3 },
|
||||||
{ "CodexMonster", 0 },
|
{ "CodexMonster", 0 },
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using Snap.Hutao.View.Dialog;
|
|||||||
using Snap.Hutao.View.Page;
|
using Snap.Hutao.View.Page;
|
||||||
using Snap.Hutao.Web.Hoyolab;
|
using Snap.Hutao.Web.Hoyolab;
|
||||||
using Snap.Hutao.Web.Hoyolab.Passport;
|
using Snap.Hutao.Web.Hoyolab.Passport;
|
||||||
|
using Snap.Hutao.Web.Hoyolab.Takumi.Binding;
|
||||||
using Snap.Hutao.Web.Response;
|
using Snap.Hutao.Web.Response;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using EntityUser = Snap.Hutao.Model.Entity.User;
|
using EntityUser = Snap.Hutao.Model.Entity.User;
|
||||||
|
|||||||
@@ -284,6 +284,25 @@ internal static class ApiEndpoints
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region HoyoPlayApi
|
||||||
|
|
||||||
|
public static string HoyoPlayConnectGamePackages(LaunchScheme scheme)
|
||||||
|
{
|
||||||
|
return $"{HoyoPlayApiConnectApi}/getGamePackages?game_ids[]={scheme.HoyoPlayGameId}&launcher_id={scheme.HoyoPlayLauncherId}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string HoyoPlayConnectGameChannelSDKs(LaunchScheme scheme)
|
||||||
|
{
|
||||||
|
return $"{HoyoPlayApiConnectApi}/getGameChannelSDKs?channel={scheme.Channel:D}&game_ids[]={scheme.HoyoPlayGameId}&launcher_id={scheme.HoyoPlayLauncherId}&sub_channel={scheme.SubChannel:D}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string HoyoPlayConnectDeprecatedFileConfigs(LaunchScheme scheme)
|
||||||
|
{
|
||||||
|
return $"{HoyoPlayApiConnectApi}/getGameDeprecatedFileConfigs?channel={scheme.Channel:D}&game_ids[]={scheme.HoyoPlayGameId}&launcher_id={scheme.HoyoPlayLauncherId}&sub_channel={scheme.SubChannel:D}";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region PassportApi | PassportApiV4
|
#region PassportApi | PassportApiV4
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -395,6 +414,9 @@ internal static class ApiEndpoints
|
|||||||
|
|
||||||
private const string Hk4eSdk = "https://hk4e-sdk.mihoyo.com";
|
private const string Hk4eSdk = "https://hk4e-sdk.mihoyo.com";
|
||||||
|
|
||||||
|
private const string HoyoPlayApi = "https://hyp-api.mihoyo.com";
|
||||||
|
private const string HoyoPlayApiConnectApi = $"{HoyoPlayApi}/hyp/hyp-connect/api";
|
||||||
|
|
||||||
private const string PassportApi = "https://passport-api.mihoyo.com";
|
private const string PassportApi = "https://passport-api.mihoyo.com";
|
||||||
private const string PassportApiAuthApi = $"{PassportApi}/account/auth/api";
|
private const string PassportApiAuthApi = $"{PassportApi}/account/auth/api";
|
||||||
private const string PassportApiV4 = "https://passport-api-v4.mihoyo.com";
|
private const string PassportApiV4 = "https://passport-api-v4.mihoyo.com";
|
||||||
|
|||||||
@@ -298,6 +298,25 @@ internal static class ApiOsEndpoints
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region SgHoyoPlayApi
|
||||||
|
|
||||||
|
public static string SgHoyoPlayConnectGamePackages(LaunchScheme scheme)
|
||||||
|
{
|
||||||
|
return $"{SgHoyoPlayApiConnectApi}/getGamePackages?game_ids[]={scheme.HoyoPlayGameId}&launcher_id={scheme.HoyoPlayLauncherId}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string SgHoyoPlayConnectGameChannelSDKs(LaunchScheme scheme)
|
||||||
|
{
|
||||||
|
return $"{SgHoyoPlayApiConnectApi}/getGameChannelSDKs?channel={scheme.Channel:D}&game_ids[]={scheme.HoyoPlayGameId}&launcher_id={scheme.HoyoPlayLauncherId}&sub_channel={scheme.SubChannel:D}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string SgHoyoPlayConnectDeprecatedFileConfigs(LaunchScheme scheme)
|
||||||
|
{
|
||||||
|
return $"{SgHoyoPlayApiConnectApi}/getGameDeprecatedFileConfigs?channel={scheme.Channel:D}&game_ids[]={scheme.HoyoPlayGameId}&launcher_id={scheme.HoyoPlayLauncherId}&sub_channel={scheme.SubChannel:D}";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region SdkOsStaticLauncherApi
|
#region SdkOsStaticLauncherApi
|
||||||
|
|
||||||
public static string SdkOsStaticLauncherResource(LaunchScheme scheme)
|
public static string SdkOsStaticLauncherResource(LaunchScheme scheme)
|
||||||
@@ -344,6 +363,9 @@ internal static class ApiOsEndpoints
|
|||||||
private const string SgPublicApi = "https://sg-public-api.hoyoverse.com";
|
private const string SgPublicApi = "https://sg-public-api.hoyoverse.com";
|
||||||
private const string SgHk4eApi = "https://sg-hk4e-api.hoyoverse.com";
|
private const string SgHk4eApi = "https://sg-hk4e-api.hoyoverse.com";
|
||||||
|
|
||||||
|
private const string SgHoyoPlayApi = "https://sg-hyp-api.hoyoverse.com";
|
||||||
|
private const string SgHoyoPlayApiConnectApi = $"{SgHoyoPlayApi}/hyp/hyp-connect/api";
|
||||||
|
|
||||||
private const string WebApiOs = "https://webapi-os.account.hoyoverse.com";
|
private const string WebApiOs = "https://webapi-os.account.hoyoverse.com";
|
||||||
private const string WebApiOsAccountApi = $"{WebApiOs}/Api";
|
private const string WebApiOsAccountApi = $"{WebApiOs}/Api";
|
||||||
|
|
||||||
|
|||||||
@@ -21,22 +21,33 @@ namespace Snap.Hutao.Web.Enka;
|
|||||||
internal sealed partial class EnkaClient
|
internal sealed partial class EnkaClient
|
||||||
{
|
{
|
||||||
private const string EnkaAPI = "https://enka.network/api/uid/{0}";
|
private const string EnkaAPI = "https://enka.network/api/uid/{0}";
|
||||||
|
private const string EnkaInfoAPI = "https://enka.network/api/uid/{0}?info";
|
||||||
|
|
||||||
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
|
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
|
||||||
private readonly JsonSerializerOptions options;
|
private readonly JsonSerializerOptions options;
|
||||||
private readonly HttpClient httpClient;
|
private readonly HttpClient httpClient;
|
||||||
|
|
||||||
|
public ValueTask<EnkaResponse?> GetForwardPlayerInfoAsync(in PlayerUid playerUid, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
return TryGetEnkaResponseCoreAsync(HutaoEndpoints.EnkaPlayerInfo(playerUid), true, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValueTask<EnkaResponse?> GetPlayerInfoAsync(in PlayerUid playerUid, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
return TryGetEnkaResponseCoreAsync(string.Format(CultureInfo.CurrentCulture, EnkaInfoAPI, playerUid), false, token);
|
||||||
|
}
|
||||||
|
|
||||||
public ValueTask<EnkaResponse?> GetForwardDataAsync(in PlayerUid playerUid, CancellationToken token = default)
|
public ValueTask<EnkaResponse?> GetForwardDataAsync(in PlayerUid playerUid, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
return TryGetEnkaResponseCoreAsync(HutaoEndpoints.Enka(playerUid), token);
|
return TryGetEnkaResponseCoreAsync(HutaoEndpoints.Enka(playerUid), true, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueTask<EnkaResponse?> GetDataAsync(in PlayerUid playerUid, CancellationToken token = default)
|
public ValueTask<EnkaResponse?> GetDataAsync(in PlayerUid playerUid, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
return TryGetEnkaResponseCoreAsync(string.Format(CultureInfo.CurrentCulture, EnkaAPI, playerUid), token);
|
return TryGetEnkaResponseCoreAsync(string.Format(CultureInfo.CurrentCulture, EnkaAPI, playerUid), false, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ValueTask<EnkaResponse?> TryGetEnkaResponseCoreAsync(string url, CancellationToken token = default)
|
private async ValueTask<EnkaResponse?> TryGetEnkaResponseCoreAsync(string url, bool isForward, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -52,6 +63,16 @@ internal sealed partial class EnkaClient
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// We want to fallback to original API and retry when requesting our forward api
|
||||||
|
if (isForward)
|
||||||
|
{
|
||||||
|
string content = await response.Content.ReadAsStringAsync(token).ConfigureAwait(false);
|
||||||
|
if (content.Contains("nginx", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/yoimiya-kokomi/miao-plugin/pull/441
|
// https://github.com/yoimiya-kokomi/miao-plugin/pull/441
|
||||||
// Additionally, HTTP codes for UID requests:
|
// Additionally, HTTP codes for UID requests:
|
||||||
// 400 = wrong UID format
|
// 400 = wrong UID format
|
||||||
|
|||||||
@@ -13,4 +13,10 @@ internal sealed class ProfilePicture
|
|||||||
{
|
{
|
||||||
[JsonPropertyName("id")]
|
[JsonPropertyName("id")]
|
||||||
public ProfilePictureId Id { get; set; }
|
public ProfilePictureId Id { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("avatarId")]
|
||||||
|
public AvatarId AvatarId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("costumeId")]
|
||||||
|
public CostumeId CostumeId { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.ChannelSDK;
|
||||||
|
|
||||||
|
internal sealed class ChannelSDK : GameSpecified
|
||||||
|
{
|
||||||
|
[JsonPropertyName("channel_sdk_pkg")]
|
||||||
|
public PackageSegment ChannelSdkPackage { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("pkg_version_file_name")]
|
||||||
|
public string PackageVersionFileName { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("version")]
|
||||||
|
public string Version { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.ChannelSDK;
|
||||||
|
|
||||||
|
internal sealed class ChannelSDKs
|
||||||
|
{
|
||||||
|
[JsonPropertyName("game_channel_sdks")]
|
||||||
|
public List<ChannelSDK> GameChannelSDKs { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile;
|
||||||
|
|
||||||
|
internal sealed class DeprecatedFile
|
||||||
|
{
|
||||||
|
[JsonPropertyName("name")]
|
||||||
|
public string Name { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile;
|
||||||
|
|
||||||
|
internal sealed class DeprecatedFileConfig : GameSpecified
|
||||||
|
{
|
||||||
|
[JsonPropertyName("deprecated_files")]
|
||||||
|
public List<DeprecatedFile> DeprecatedFiles { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile;
|
||||||
|
|
||||||
|
internal sealed class DeprecatedFileConfigs
|
||||||
|
{
|
||||||
|
[JsonPropertyName("deprecated_file_configs")]
|
||||||
|
public List<DeprecatedFileConfig> Configs { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect;
|
||||||
|
|
||||||
|
internal sealed class Game
|
||||||
|
{
|
||||||
|
[JsonPropertyName("id")]
|
||||||
|
public string Id { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("biz")]
|
||||||
|
public string Biz { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect;
|
||||||
|
|
||||||
|
internal class GameSpecified
|
||||||
|
{
|
||||||
|
[JsonPropertyName("game")]
|
||||||
|
public Game Game { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||||
|
using Snap.Hutao.Service.Game.Scheme;
|
||||||
|
using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.ChannelSDK;
|
||||||
|
using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.DeprecatedFile;
|
||||||
|
using Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||||
|
using Snap.Hutao.Web.Request.Builder;
|
||||||
|
using Snap.Hutao.Web.Request.Builder.Abstraction;
|
||||||
|
using Snap.Hutao.Web.Response;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect;
|
||||||
|
|
||||||
|
[ConstructorGenerated(ResolveHttpClient = true)]
|
||||||
|
[HttpClient(HttpClientConfiguration.Default)]
|
||||||
|
internal sealed partial class HoyoPlayClient
|
||||||
|
{
|
||||||
|
private readonly IHttpRequestMessageBuilderFactory httpRequestMessageBuilderFactory;
|
||||||
|
private readonly HttpClient httpClient;
|
||||||
|
private readonly ILogger<HoyoPlayClient> logger;
|
||||||
|
|
||||||
|
public async ValueTask<Response<GamePackages>> GetPackagesAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
string url = scheme.IsOversea
|
||||||
|
? ApiOsEndpoints.SgHoyoPlayConnectGamePackages(scheme)
|
||||||
|
: ApiEndpoints.HoyoPlayConnectGamePackages(scheme);
|
||||||
|
|
||||||
|
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||||
|
.SetRequestUri(url)
|
||||||
|
.Get();
|
||||||
|
|
||||||
|
Response<GamePackages>? resp = await builder
|
||||||
|
.SendAsync<Response<GamePackages>>(httpClient, logger, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
return Response.Response.DefaultIfNull(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Response<ChannelSDKs>> GetChannelSDKAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
string url = scheme.IsOversea
|
||||||
|
? ApiOsEndpoints.SgHoyoPlayConnectGameChannelSDKs(scheme)
|
||||||
|
: ApiEndpoints.HoyoPlayConnectGameChannelSDKs(scheme);
|
||||||
|
|
||||||
|
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||||
|
.SetRequestUri(url)
|
||||||
|
.Get();
|
||||||
|
|
||||||
|
Response<ChannelSDKs>? resp = await builder
|
||||||
|
.SendAsync<Response<ChannelSDKs>>(httpClient, logger, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
return Response.Response.DefaultIfNull(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Response<DeprecatedFileConfigs>> GetDeprecatedFilesAsync(LaunchScheme scheme, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
string url = scheme.IsOversea
|
||||||
|
? ApiOsEndpoints.SgHoyoPlayConnectDeprecatedFileConfigs(scheme)
|
||||||
|
: ApiEndpoints.HoyoPlayConnectDeprecatedFileConfigs(scheme);
|
||||||
|
|
||||||
|
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||||
|
.SetRequestUri(url)
|
||||||
|
.Get();
|
||||||
|
|
||||||
|
Response<DeprecatedFileConfigs>? resp = await builder
|
||||||
|
.SendAsync<Response<DeprecatedFileConfigs>>(httpClient, logger, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
return Response.Response.DefaultIfNull(resp);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||||
|
|
||||||
|
internal sealed class AudioPackageSegment : PackageSegment
|
||||||
|
{
|
||||||
|
[JsonPropertyName("language")]
|
||||||
|
public string Language { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||||
|
|
||||||
|
internal sealed class GameBranch
|
||||||
|
{
|
||||||
|
[JsonPropertyName("major")]
|
||||||
|
public Package? Major { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("patches")]
|
||||||
|
public List<Package> Patches { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||||
|
|
||||||
|
internal sealed class GamePackage : GameSpecified
|
||||||
|
{
|
||||||
|
[JsonPropertyName("main")]
|
||||||
|
public GameBranch Main { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("pre_download")]
|
||||||
|
public GameBranch PreDownload { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||||
|
|
||||||
|
internal sealed class GamePackages
|
||||||
|
{
|
||||||
|
[JsonPropertyName("game_packages")]
|
||||||
|
public List<GamePackage> Packages { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect.Package;
|
||||||
|
|
||||||
|
internal sealed class Package
|
||||||
|
{
|
||||||
|
[JsonPropertyName("version")]
|
||||||
|
public string Version { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("game_pkgs")]
|
||||||
|
public List<PackageSegment> GamePackages { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("audio_pkgs")]
|
||||||
|
public List<AudioPackageSegment> AudioPackages { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("res_list_url")]
|
||||||
|
public string ResListUrl { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<PackageSegment> AllPackages
|
||||||
|
{
|
||||||
|
get => [.. GamePackages, .. AudioPackages];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Core.IO.DataTransfer;
|
||||||
|
using Snap.Hutao.Service.Notification;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hoyolab.HoyoPlay.Connect;
|
||||||
|
|
||||||
|
internal partial class PackageSegment
|
||||||
|
{
|
||||||
|
[JsonPropertyName("url")]
|
||||||
|
public string Url { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("md5")]
|
||||||
|
public string Md5 { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("size")]
|
||||||
|
public long Size { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("decompressed_size")]
|
||||||
|
public long DecompressedSize { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string DisplayName { get => System.IO.Path.GetFileName(Url); }
|
||||||
|
|
||||||
|
[Command("CopyPathCommand")]
|
||||||
|
private void CopyPathToClipboard()
|
||||||
|
{
|
||||||
|
IServiceProvider serviceProvider = Ioc.Default;
|
||||||
|
serviceProvider.GetRequiredService<IClipboardProvider>().SetText(Url);
|
||||||
|
serviceProvider.GetRequiredService<IInfoBarService>().Success(SH.WebGameResourcePathCopySucceed);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,21 @@
|
|||||||
// 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 CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Snap.Hutao.Service.User;
|
||||||
|
|
||||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.Binding;
|
namespace Snap.Hutao.Web.Hoyolab.Takumi.Binding;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户游戏角色
|
/// 用户游戏角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HighQuality]
|
[HighQuality]
|
||||||
internal sealed class UserGameRole
|
internal sealed class UserGameRole : ObservableObject
|
||||||
{
|
{
|
||||||
|
private string? profilePictureIcon;
|
||||||
|
private ICommand? refreshProfilePictureCommand;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// hk4e_cn for Genshin Impact
|
/// hk4e_cn for Genshin Impact
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -65,6 +72,18 @@ internal sealed class UserGameRole
|
|||||||
get => $"{RegionName} | Lv.{Level}";
|
get => $"{RegionName} | Lv.{Level}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string? ProfilePictureIcon
|
||||||
|
{
|
||||||
|
get => profilePictureIcon;
|
||||||
|
set => SetProperty(ref profilePictureIcon, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand RefreshProfilePictureCommand
|
||||||
|
{
|
||||||
|
get => refreshProfilePictureCommand ??= new AsyncRelayCommand(RefreshProfilePictureAsync);
|
||||||
|
}
|
||||||
|
|
||||||
public static implicit operator PlayerUid(UserGameRole userGameRole)
|
public static implicit operator PlayerUid(UserGameRole userGameRole)
|
||||||
{
|
{
|
||||||
return new PlayerUid(userGameRole.GameUid, userGameRole.Region);
|
return new PlayerUid(userGameRole.GameUid, userGameRole.Region);
|
||||||
@@ -75,4 +94,10 @@ internal sealed class UserGameRole
|
|||||||
{
|
{
|
||||||
return $"{Nickname} | {RegionName} | Lv.{Level}";
|
return $"{Nickname} | {RegionName} | Lv.{Level}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SuppressMessage("", "SH003")]
|
||||||
|
private async Task RefreshProfilePictureAsync()
|
||||||
|
{
|
||||||
|
await Ioc.Default.GetRequiredService<IUserService>().RefreshProfilePictureAsync(this).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -212,6 +212,11 @@ internal static class HutaoEndpoints
|
|||||||
return $"{ApiSnapGenshinEnka}/{uid}";
|
return $"{ApiSnapGenshinEnka}/{uid}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string EnkaPlayerInfo(in PlayerUid uid)
|
||||||
|
{
|
||||||
|
return $"{ApiSnapGenshinEnka}/{uid}/info";
|
||||||
|
}
|
||||||
|
|
||||||
public const string Ip = $"{ApiSnapGenshin}/ip";
|
public const string Ip = $"{ApiSnapGenshin}/ip";
|
||||||
|
|
||||||
#region Metadata
|
#region Metadata
|
||||||
|
|||||||
Reference in New Issue
Block a user