was 1.2.0

This commit is contained in:
DismissedLight
2022-11-11 17:20:36 +08:00
parent 5c1f861956
commit aac1e62fd2
11 changed files with 183 additions and 48 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-windows10.0.17763.0</TargetFrameworks>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<TargetFrameworks>net7.0-windows10.0.18362.0</TargetFrameworks>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<RootNamespace>SettingsUI</RootNamespace>
<Platforms>x64</Platforms>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
@@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.4" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.221109.1" />
</ItemGroup>
<ItemGroup>

View File

@@ -8,6 +8,7 @@
<PublishTrimmed>true</PublishTrimmed>
<ApplicationManifest>app.manifest</ApplicationManifest>
<DebugType>embedded</DebugType>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
</Project>

View File

@@ -14,7 +14,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SettingsUI", "SettingsUI\Se
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Snap.Hutao.SourceGeneration", "Snap.Hutao.SourceGeneration\Snap.Hutao.SourceGeneration.csproj", "{8B96721E-5604-47D2-9B72-06FEBAD0CE00}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snap.Hutao.Installer", "Snap.Hutao.Installer\Snap.Hutao.Installer.csproj", "{CEC01691-F65E-4874-9AE2-F571369A7631}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Snap.Hutao.Installer", "Snap.Hutao.Installer\Snap.Hutao.Installer.csproj", "{CEC01691-F65E-4874-9AE2-F571369A7631}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -88,8 +88,8 @@ Global
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|arm64.ActiveCfg = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|arm64.Build.0 = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|x64.ActiveCfg = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|x64.Build.0 = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|x64.ActiveCfg = Debug|x64
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|x64.Build.0 = Debug|x64
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|x86.ActiveCfg = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Debug|x86.Build.0 = Debug|Any CPU
{CEC01691-F65E-4874-9AE2-F571369A7631}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@@ -1,14 +1,13 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using CommunityToolkit.WinUI.Notifications;
using Microsoft.UI.Xaml;
using Microsoft.Windows.AppLifecycle;
using Snap.Hutao.Core;
using Snap.Hutao.Core.Exception;
using Snap.Hutao.Core.LifeCycle;
using Snap.Hutao.Core.Logging;
using Snap.Hutao.Extension;
using Snap.Hutao.Service.Metadata;
using System.Diagnostics;
using Windows.Storage;
@@ -48,6 +47,7 @@ public partial class App : Application
// manually invoke
Activation.Activate(firstInstance, activatedEventArgs);
firstInstance.Activated += Activation.Activate;
ToastNotificationManagerCompat.OnActivated += Activation.NotificationActivate;
logger.LogInformation(EventIds.CommonLog, "Snap Hutao | {name} : {version}", CoreEnvironment.FamilyName, CoreEnvironment.Version);
logger.LogInformation(EventIds.CommonLog, "Cache folder : {folder}", ApplicationData.Current.TemporaryFolder.Path);

View File

@@ -1,6 +1,7 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using CommunityToolkit.WinUI.Notifications;
using Microsoft.Windows.AppLifecycle;
using Snap.Hutao.Extension;
using Snap.Hutao.Service.Abstraction;
@@ -45,7 +46,29 @@ internal static class Activation
public static void Activate(object? sender, AppActivationArguments args)
{
_ = sender;
HandleActivationAsync(args).SafeForget();
if (!ToastNotificationManagerCompat.WasCurrentProcessToastActivated())
{
HandleActivationAsync(args).SafeForget();
}
}
/// <summary>
/// 响应通知激活事件
/// </summary>
/// <param name="args">参数</param>
public static void NotificationActivate(ToastNotificationActivatedEventArgsCompat args)
{
ToastArguments toastArgs = ToastArguments.Parse(args.Argument);
_ = toastArgs;
if (toastArgs.TryGetValue("Action", out string? action))
{
if (action == LaunchGame)
{
_ = toastArgs.TryGetValue("Uid", out string? uid);
HandleLaunchGameActionAsync(uid).SafeForget();
}
}
}
/// <summary>
@@ -87,18 +110,7 @@ internal static class Activation
case LaunchGame:
{
await ThreadHelper.SwitchToMainThreadAsync();
if (!MainWindow.IsPresent)
{
_ = Ioc.Default.GetRequiredService<LaunchGameWindow>();
}
else
{
await Ioc.Default
.GetRequiredService<INavigationService>()
.NavigateAsync<View.Page.LaunchGamePage>(INavigationAwaiter.Default, true).ConfigureAwait(false);
}
await HandleLaunchGameActionAsync().ConfigureAwait(false);
break;
}
}
@@ -108,6 +120,7 @@ internal static class Activation
private static async Task WaitMainWindowAsync()
{
await ThreadHelper.SwitchToMainThreadAsync();
_ = Ioc.Default.GetRequiredService<MainWindow>();
await Ioc.Default.GetRequiredService<IInfoBarService>().WaitInitializationAsync().ConfigureAwait(false);
@@ -177,4 +190,21 @@ internal static class Activation
}
}
}
private static async Task HandleLaunchGameActionAsync(string? uid = null)
{
await ThreadHelper.SwitchToMainThreadAsync();
// TODO auto switch to account
if (!MainWindow.IsPresent)
{
_ = Ioc.Default.GetRequiredService<LaunchGameWindow>();
}
else
{
await Ioc.Default
.GetRequiredService<INavigationService>()
.NavigateAsync<View.Page.LaunchGamePage>(INavigationAwaiter.Default, true).ConfigureAwait(false);
}
}
}

View File

@@ -2,15 +2,17 @@
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap desktop6 rescap">
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
IgnorableNamespaces="com uap desktop desktop6 rescap">
<Identity
Name="7f0db578-026f-4e0b-a75b-d5d06bb0a74d"
Publisher="CN=DGP Studio"
Version="1.1.23.0" />
Version="1.2.0.0" />
<Properties>
<DisplayName>胡桃</DisplayName>
@@ -22,7 +24,7 @@
<Dependencies>
<!--<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />-->
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22000.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18362.0" MaxVersionTested="10.0.22000.0" />
</Dependencies>
<Resources>
@@ -43,6 +45,16 @@
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<desktop:Extension Category="windows.toastNotificationActivation">
<desktop:ToastNotificationActivation ToastActivatorCLSID="5760ec4d-f7e8-4666-a965-9886d7dffe7d"/>
</desktop:Extension>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:ExeServer Executable="Snap.Hutao.exe" Arguments="-ToastActivated" DisplayName="Snap Hutao Toast Activator">
<com:Class Id="5760ec4d-f7e8-4666-a965-9886d7dffe7d" DisplayName="Snap Hutao Toast Activator"/>
</com:ExeServer>
</com:ComServer>
</com:Extension>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="hutao">
<uap:DisplayName>胡桃</uap:DisplayName>

View File

@@ -83,5 +83,6 @@ internal static partial class ReliquaryWeightConfiguration
new(AvatarIds.Nilou, 100, 75, 0, 100, 100, 0, 55, 0, "反应流") { { FightProperty.FIGHT_PROP_WATER_ADD_HURT, 100 } },
new(AvatarIds.Cyno, 0, 75, 0, 100, 100, 75, 55, 0) { { FightProperty.FIGHT_PROP_ELEC_ADD_HURT, 100 } },
new(AvatarIds.Candace, 100, 75, 0, 100, 100, 0, 55, 0) { { FightProperty.FIGHT_PROP_WATER_ADD_HURT, 100 } },
new(AvatarIds.Nahida, 0, 55, 0, 100, 100, 100, 55, 0) { { FightProperty.FIGHT_PROP_GRASS_ADD_HURT, 100 } },
};
}

View File

@@ -2,6 +2,7 @@
// Licensed under the MIT license.
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI.Notifications;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Snap.Hutao.Context.Database;
@@ -11,6 +12,7 @@ using Snap.Hutao.Message;
using Snap.Hutao.Model.Binding.User;
using Snap.Hutao.Model.Entity;
using Snap.Hutao.Service.User;
using Snap.Hutao.Web.Hoyolab.Takumi.Binding;
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.DailyNote;
using System.Collections.ObjectModel;
@@ -96,6 +98,7 @@ internal class DailyNoteService : IDailyNoteService, IRecipient<UserRemovedMessa
{
AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
GameRecordClient gameRecordClient = scope.ServiceProvider.GetRequiredService<GameRecordClient>();
BindingClient bindingClient = scope.ServiceProvider.GetRequiredService<BindingClient>();
foreach (DailyNoteEntry entry in appDbContext.DailyNotes.Include(n => n.User))
{
@@ -111,7 +114,7 @@ internal class DailyNoteService : IDailyNoteService, IRecipient<UserRemovedMessa
if (notify)
{
await NotifyDailyNoteAsync(entry).ConfigureAwait(false);
await NotifyDailyNoteAsync(bindingClient, entry).ConfigureAwait(false);
}
}
@@ -131,7 +134,7 @@ internal class DailyNoteService : IDailyNoteService, IRecipient<UserRemovedMessa
}
}
private async ValueTask NotifyDailyNoteAsync(DailyNoteEntry entry)
private async ValueTask NotifyDailyNoteAsync(BindingClient client,DailyNoteEntry entry)
{
if (entry.DailyNote == null)
{
@@ -139,34 +142,111 @@ internal class DailyNoteService : IDailyNoteService, IRecipient<UserRemovedMessa
}
List<string> hints = new();
if (!entry.ResinNotifySuppressed && entry.DailyNote.CurrentResin >= entry.ResinNotifyThreshold)
// NotifySuppressed judge
{
hints.Add($"当前原粹树脂:{entry.DailyNote.CurrentResin}");
entry.ResinNotifySuppressed = true;
if (entry.DailyNote.CurrentResin >= entry.ResinNotifyThreshold)
{
if (!entry.ResinNotifySuppressed)
{
hints.Add($"当前原粹树脂:{entry.DailyNote.CurrentResin}");
entry.ResinNotifySuppressed = true;
}
}
else
{
entry.ResinNotifySuppressed = false;
}
if (entry.DailyNote.CurrentHomeCoin >= entry.HomeCoinNotifyThreshold)
{
if (!entry.HomeCoinNotifySuppressed)
{
hints.Add($"当前洞天宝钱:{entry.DailyNote.CurrentHomeCoin}");
entry.HomeCoinNotifySuppressed = true;
}
}
else
{
entry.HomeCoinNotifySuppressed = false;
}
if (entry.DailyTaskNotify && !entry.DailyNote.IsExtraTaskRewardReceived)
{
if (!entry.DailyTaskNotifySuppressed)
{
hints.Add(entry.DailyNote.ExtraTaskRewardDescription);
entry.DailyTaskNotifySuppressed = true;
}
}
else
{
entry.DailyTaskNotifySuppressed = false;
}
if (entry.TransformerNotify && entry.DailyNote.Transformer.Obtained && entry.DailyNote.Transformer.RecoveryTime.Reached)
{
if (!entry.TransformerNotifySuppressed)
{
hints.Add("参量质变仪已准备完成");
entry.TransformerNotifySuppressed = true;
}
}
else
{
entry.TransformerNotifySuppressed = false;
}
if (entry.ExpeditionNotify && entry.DailyNote.Expeditions.All(e => e.Status == ExpeditionStatus.Finished))
{
if (!entry.ExpeditionNotifySuppressed)
{
hints.Add("探索派遣已完成");
entry.ExpeditionNotifySuppressed = true;
}
}
else
{
entry.ExpeditionNotifySuppressed = false;
}
}
if (!entry.HomeCoinNotifySuppressed && entry.DailyNote.CurrentHomeCoin >= entry.HomeCoinNotifyThreshold)
if (hints.Count <= 0)
{
hints.Add($"当前洞天宝钱:{entry.DailyNote.CurrentHomeCoin}");
entry.HomeCoinNotifySuppressed = true;
return;
}
if (!entry.DailyTaskNotifySuppressed && entry.DailyTaskNotify && !entry.DailyNote.IsExtraTaskRewardReceived)
List<UserGameRole> roles = await client.GetUserGameRolesAsync(entry.User).ConfigureAwait(false);
string attribution = roles.SingleOrDefault(r => r.GameUid == entry.Uid)?.ToString() ?? "未知角色";
ToastContentBuilder builder = new ToastContentBuilder()
.AddHeader("DAILYNOTE", "实时便笺提醒", "DAILYNOTE")
.AddAttributionText(attribution)
.AddButton(new ToastButton().SetContent("开始游戏").AddArgument("Action", "LaunchGame").AddArgument("Uid", entry.Uid))
.AddButton(new ToastButtonDismiss("我知道了"));
using (IServiceScope scope = scopeFactory.CreateScope())
{
hints.Add(entry.DailyNote.ExtraTaskRewardDescription);
entry.DailyTaskNotifySuppressed = true;
AppDbContext appDbContext = scope.ServiceProvider.GetRequiredService<AppDbContext>();
if (appDbContext.Settings.SingleOrAdd(SettingEntry.DailyNoteReminderNotify, false.ToString()).GetBoolean())
{
builder.SetToastScenario(ToastScenario.Reminder);
}
}
if (!entry.TransformerNotifySuppressed && entry.TransformerNotify && entry.DailyNote.Transformer.Obtained && entry.DailyNote.Transformer.RecoveryTime.Reached)
if (hints.Count > 2)
{
hints.Add("参量质变仪已准备完成");
entry.TransformerNotifySuppressed = true;
builder.AddText("多个提醒项达到设定值");
}
else
{
foreach (string hint in hints)
{
builder.AddText(hint);
}
}
if (!entry.ExpeditionNotifySuppressed && entry.ExpeditionNotify && entry.DailyNote.Expeditions.All(e => e.Status == ExpeditionStatus.Finished))
{
hints.Add("探索派遣已完成");
entry.ExpeditionNotifySuppressed = true;
}
await ThreadHelper.SwitchToMainThreadAsync();
builder.Show();
}
}

View File

@@ -20,7 +20,7 @@
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<PackageCertificateThumbprint>F8C2255969BEA4A681CED102771BF807856AEC02</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundle>Never</AppxBundle>
@@ -145,7 +145,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25231-preview" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.220930.4-preview2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.2.221109.1" />
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.435">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@@ -38,7 +38,18 @@ internal class BindingClient
/// <param name="user">用户</param>
/// <param name="token">取消令牌</param>
/// <returns>用户角色信息</returns>
public async Task<List<UserGameRole>> GetUserGameRolesAsync(User user, CancellationToken token = default)
public Task<List<UserGameRole>> GetUserGameRolesAsync(User user, CancellationToken token = default)
{
return GetUserGameRolesAsync(user.Entity, token);
}
/// <summary>
/// 获取用户角色信息
/// </summary>
/// <param name="user">用户</param>
/// <param name="token">取消令牌</param>
/// <returns>用户角色信息</returns>
public async Task<List<UserGameRole>> GetUserGameRolesAsync(Model.Entity.User user, CancellationToken token = default)
{
Response<ListWrapper<UserGameRole>>? resp = await httpClient
.SetUser(user)

View File

@@ -14,7 +14,7 @@ public class Expedition
private const string Keqing = "https://upload-bbs.mihoyo.com/game_record/genshin/character_side_icon/UI_AvatarIcon_Side_Keqing.png";
private const string Sara = "https://upload-bbs.mihoyo.com/game_record/genshin/character_side_icon/UI_AvatarIcon_Side_Sara.png";
private static readonly List<string> ShortExpeditionTimeAvatars = new List<string>()
private static readonly List<string> ShortExpeditionTimeAvatars = new()
{
Bennett, Chongyun, Fischl, Keqing, Sara,
};