fix ci build

This commit is contained in:
DismissedLight
2022-12-18 15:23:43 +08:00
parent 7457d72e1b
commit 0073636676
16 changed files with 119 additions and 44 deletions

View File

@@ -8,12 +8,20 @@ body:
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
请按下方的要求填写完整的问题表单,以便我们更快的定位问题 请按下方的要求填写完整的问题表单。
- type: textarea - type: textarea
id: req id: req
attributes: attributes:
label: 你想要实现或优化的功能? label: 背景与动机
description: 详细的描述一下你想要的功能 description: 添加此功能的理由
validations:
required: true
- type: textarea
id: req
attributes:
label: 想要实现或优化的功能
description: 详细的描述一下你想要的功能,描述的越具体,采纳的可能性越高
validations: validations:
required: true required: true

View File

@@ -6,8 +6,9 @@
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers> <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI> <UseWinUI>true</UseWinUI>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -46,7 +46,7 @@ public partial class App : Application
if (firstInstance.IsCurrent) if (firstInstance.IsCurrent)
{ {
// manually invoke // manually invoke
Activation.Activate(firstInstance, activatedEventArgs); Activation.NonRedirectToActivate(firstInstance, activatedEventArgs);
firstInstance.Activated += Activation.Activate; firstInstance.Activated += Activation.Activate;
ToastNotificationManagerCompat.OnActivated += Activation.NotificationActivate; ToastNotificationManagerCompat.OnActivated += Activation.NotificationActivate;

View File

@@ -37,12 +37,6 @@ public class CommandLineBuilder
return this; return this;
} }
/// <inheritdoc cref="ToString"/>
public string Build()
{
return ToString();
}
/// <inheritdoc/> /// <inheritdoc/>
public override string ToString() public override string ToString()
{ {

View File

@@ -28,7 +28,7 @@ internal static class CoreEnvironment
/// <summary> /// <summary>
/// 米游社 Rpc 版本 /// 米游社 Rpc 版本
/// </summary> /// </summary>
public const string HoyolabXrpcVersion = "2.41.0"; public const string HoyolabXrpcVersion = "2.42.1";
/// <summary> /// <summary>
/// 标准UA /// 标准UA

View File

@@ -49,7 +49,21 @@ internal static class Activation
_ = sender; _ = sender;
if (!ToastNotificationManagerCompat.WasCurrentProcessToastActivated()) if (!ToastNotificationManagerCompat.WasCurrentProcessToastActivated())
{ {
HandleActivationAsync(args).SafeForget(); HandleActivationAsync(args, true).SafeForget();
}
}
/// <summary>
/// 触发激活事件
/// </summary>
/// <param name="sender">发送方</param>
/// <param name="args">激活参数</param>
public static void NonRedirectToActivate(object? sender, AppActivationArguments args)
{
_ = sender;
if (!ToastNotificationManagerCompat.WasCurrentProcessToastActivated())
{
HandleActivationAsync(args, false).SafeForget();
} }
} }
@@ -76,24 +90,24 @@ internal static class Activation
/// 异步响应激活事件 /// 异步响应激活事件
/// </summary> /// </summary>
/// <returns>任务</returns> /// <returns>任务</returns>
private static async Task HandleActivationAsync(AppActivationArguments args) private static async Task HandleActivationAsync(AppActivationArguments args, bool isRedirected)
{ {
if (ActivateSemaphore.CurrentCount > 0) if (ActivateSemaphore.CurrentCount > 0)
{ {
using (await ActivateSemaphore.EnterAsync().ConfigureAwait(false)) using (await ActivateSemaphore.EnterAsync().ConfigureAwait(false))
{ {
await HandleActivationCoreAsync(args).ConfigureAwait(false); await HandleActivationCoreAsync(args, isRedirected).ConfigureAwait(false);
} }
} }
} }
private static async Task HandleActivationCoreAsync(AppActivationArguments args) private static async Task HandleActivationCoreAsync(AppActivationArguments args, bool isRedirected)
{ {
if (args.Kind == ExtendedActivationKind.Protocol) if (args.Kind == ExtendedActivationKind.Protocol)
{ {
if (args.TryGetProtocolActivatedUri(out Uri? uri)) if (args.TryGetProtocolActivatedUri(out Uri? uri))
{ {
await HandleUrlActivationAsync(uri).ConfigureAwait(false); await HandleUrlActivationAsync(uri, isRedirected).ConfigureAwait(false);
} }
} }
else if (args.Kind == ExtendedActivationKind.Launch) else if (args.Kind == ExtendedActivationKind.Launch)
@@ -131,7 +145,7 @@ internal static class Activation
.SafeForget(); .SafeForget();
} }
private static async Task HandleUrlActivationAsync(Uri uri) private static async Task HandleUrlActivationAsync(Uri uri, bool isRedirected)
{ {
UriBuilder builder = new(uri); UriBuilder builder = new(uri);
@@ -144,21 +158,22 @@ internal static class Activation
case "achievement": case "achievement":
{ {
await WaitMainWindowAsync().ConfigureAwait(false); await WaitMainWindowAsync().ConfigureAwait(false);
await HandleAchievementActionAsync(action, parameter).ConfigureAwait(false); await HandleAchievementActionAsync(action, parameter, isRedirected).ConfigureAwait(false);
break; break;
} }
case "dailynote": case "dailynote":
{ {
await HandleDailyNoteActionAsync(action, parameter).ConfigureAwait(false); await HandleDailyNoteActionAsync(action, parameter, isRedirected).ConfigureAwait(false);
break; break;
} }
} }
} }
private static async Task HandleAchievementActionAsync(string action, string parameter) private static async Task HandleAchievementActionAsync(string action, string parameter, bool isRedirected)
{ {
_ = parameter; _ = parameter;
_ = isRedirected;
switch (action) switch (action)
{ {
case "/import": case "/import":
@@ -175,7 +190,7 @@ internal static class Activation
} }
} }
private static async Task HandleDailyNoteActionAsync(string action, string parameter) private static async Task HandleDailyNoteActionAsync(string action, string parameter, bool isRedirected)
{ {
_ = parameter; _ = parameter;
switch (action) switch (action)
@@ -186,6 +201,14 @@ internal static class Activation
.GetRequiredService<IDailyNoteService>() .GetRequiredService<IDailyNoteService>()
.RefreshDailyNotesAsync(true) .RefreshDailyNotesAsync(true)
.ConfigureAwait(false); .ConfigureAwait(false);
// Check if it's redirected.
if (!isRedirected)
{
// It's a direct open process, should exit immediately.
Environment.Exit(0);
}
break; break;
} }
} }

View File

@@ -19,14 +19,13 @@ internal static class AppInstanceExtension
/// </summary> /// </summary>
/// <param name="appInstance">app实例</param> /// <param name="appInstance">app实例</param>
/// <param name="args">参数</param> /// <param name="args">参数</param>
[SuppressMessage("", "VSTHRD002")]
[SuppressMessage("", "VSTHRD110")] [SuppressMessage("", "VSTHRD110")]
public static unsafe void RedirectActivationTo(this AppInstance appInstance, AppActivationArguments args) public static void RedirectActivationTo(this AppInstance appInstance, AppActivationArguments args)
{ {
HANDLE redirectEventHandle = CreateEvent((SECURITY_ATTRIBUTES*)null, true, false, null); HANDLE redirectEventHandle = UnsafeCreateEvent();
Task.Run(() => Task.Run(async () =>
{ {
appInstance.RedirectActivationToAsync(args).AsTask().Wait(); await appInstance.RedirectActivationToAsync(args);
SetEvent(redirectEventHandle); SetEvent(redirectEventHandle);
}); });
@@ -35,4 +34,9 @@ internal static class AppInstanceExtension
// non-blocking // non-blocking
CoWaitForMultipleObjects((uint)CWMO_FLAGS.CWMO_DEFAULT, INFINITE, handles, out uint _); CoWaitForMultipleObjects((uint)CWMO_FLAGS.CWMO_DEFAULT, INFINITE, handles, out uint _);
} }
private static unsafe HANDLE UnsafeCreateEvent()
{
return CreateEvent((SECURITY_ATTRIBUTES*)null, true, false, null);
}
} }

View File

@@ -45,4 +45,30 @@ internal static class TaskSchedulerHelper
return false; return false;
} }
} }
/// <summary>
/// 卸载全部注册的任务
/// </summary>
/// <returns>是否卸载成功</returns>
public static bool UnregisterAllTasks()
{
try
{
SchedulerTask? targetTask = TaskService.Instance.GetTask(DailyNoteRefreshTaskName);
if (targetTask != null)
{
TaskService.Instance.RootFolder.DeleteTask(DailyNoteRefreshTaskName);
}
return true;
}
catch (UnauthorizedAccessException)
{
return false;
}
catch (COMException)
{
return false;
}
}
} }

View File

@@ -20,7 +20,7 @@ internal class Team : List<ComplexAvatar>
public Team(ItemRate<string, int> team, Dictionary<AvatarId, Avatar> idAvatarMap) public Team(ItemRate<string, int> team, Dictionary<AvatarId, Avatar> idAvatarMap)
: base(4) : base(4)
{ {
IEnumerable<int> ids = team.Item.Split(',').Select(int.Parse); IOrderedEnumerable<int> ids = team.Item.Split(',').Select(int.Parse).OrderByDescending(x => x);
foreach (int id in ids) foreach (int id in ids)
{ {

View File

@@ -246,7 +246,7 @@ internal class GameService : IGameService, IDisposable
.Append("-screen-fullscreen", configuration.IsFullScreen ? 1 : 0) .Append("-screen-fullscreen", configuration.IsFullScreen ? 1 : 0)
.Append("-screen-width", configuration.ScreenWidth) .Append("-screen-width", configuration.ScreenWidth)
.Append("-screen-height", configuration.ScreenHeight) .Append("-screen-height", configuration.ScreenHeight)
.Build(); .ToString();
Process game = new() Process game = new()
{ {
@@ -310,10 +310,6 @@ internal class GameService : IGameService, IDisposable
{ {
account = GameAccount.Create(name, registrySdk); account = GameAccount.Create(name, registrySdk);
// sync cache
await ThreadHelper.SwitchToMainThreadAsync();
gameAccounts.Add(GameAccount.Create(name, registrySdk));
// sync database // sync database
await ThreadHelper.SwitchToBackgroundAsync(); await ThreadHelper.SwitchToBackgroundAsync();
using (IServiceScope scope = scopeFactory.CreateScope()) using (IServiceScope scope = scopeFactory.CreateScope())
@@ -324,6 +320,10 @@ internal class GameService : IGameService, IDisposable
.AddAndSaveAsync(account) .AddAndSaveAsync(account)
.ConfigureAwait(false); .ConfigureAwait(false);
} }
// sync cache
await ThreadHelper.SwitchToMainThreadAsync();
gameAccounts.Add(account);
} }
} }
} }

View File

@@ -5,7 +5,9 @@
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion> <TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<RootNamespace>Snap.Hutao</RootNamespace> <RootNamespace>Snap.Hutao</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<Platform>x64</Platform>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers> <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile> <PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI> <UseWinUI>true</UseWinUI>
@@ -153,7 +155,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Validation" Version="17.0.64" /> <PackageReference Include="Microsoft.VisualStudio.Validation" Version="17.0.64" />
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.164-beta"> <PackageReference Include="Microsoft.Windows.CsWin32" Version="0.2.138-beta">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@@ -50,9 +50,6 @@ public sealed partial class DailyNoteVerificationDialog : ContentDialog
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent(); coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
dailyNoteJsInterface = new(coreWebView2, scope.ServiceProvider); dailyNoteJsInterface = new(coreWebView2, scope.ServiceProvider);
#if DEBUG
coreWebView2.OpenDevToolsWindow();
#endif
string query = $"?role_id={uid.Value}&server={uid.Region}"; string query = $"?role_id={uid.Value}&server={uid.Region}";
coreWebView2.Navigate($"https://webstatic.mihoyo.com/app/community-game-records/index.html?bbs_presentation_style=fullscreen#/ys/daily/{query}"); coreWebView2.Navigate($"https://webstatic.mihoyo.com/app/community-game-records/index.html?bbs_presentation_style=fullscreen#/ys/daily/{query}");
} }

View File

@@ -49,10 +49,6 @@ public sealed partial class SignInWebViewDialog : ContentDialog
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent(); coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
signInJsInterface = new(coreWebView2, scope.ServiceProvider); signInJsInterface = new(coreWebView2, scope.ServiceProvider);
#if DEBUG
coreWebView2.OpenDevToolsWindow();
#endif
coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501"); coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501");
} }

View File

@@ -87,6 +87,10 @@
</Flyout> </Flyout>
</AppBarButton.Flyout> </AppBarButton.Flyout>
</AppBarButton> </AppBarButton>
<AppBarButton
Command="{Binding DailyNoteVerificationCommand}"
Icon="{shcm:FontIcon Glyph=&#xE9D5;}"
Label="验证当前账号角色"/>
<AppBarButton Icon="{shcm:FontIcon Glyph=&#xE713;}" Label="通知设置"> <AppBarButton Icon="{shcm:FontIcon Glyph=&#xE713;}" Label="通知设置">
<AppBarButton.Flyout> <AppBarButton.Flyout>
<Flyout Placement="BottomEdgeAlignedRight"> <Flyout Placement="BottomEdgeAlignedRight">

View File

@@ -11,6 +11,7 @@ using Snap.Hutao.Factory.Abstraction;
using Snap.Hutao.Model; using Snap.Hutao.Model;
using Snap.Hutao.Model.Binding.User; using Snap.Hutao.Model.Binding.User;
using Snap.Hutao.Model.Entity; using Snap.Hutao.Model.Entity;
using Snap.Hutao.Service.Abstraction;
using Snap.Hutao.Service.DailyNote; using Snap.Hutao.Service.DailyNote;
using Snap.Hutao.Service.User; using Snap.Hutao.Service.User;
using Snap.Hutao.View.Dialog; using Snap.Hutao.View.Dialog;
@@ -67,6 +68,7 @@ internal class DailyNoteViewModel : ObservableObject, ISupportCancellation
RefreshCommand = asyncRelayCommandFactory.Create(RefreshAsync); RefreshCommand = asyncRelayCommandFactory.Create(RefreshAsync);
RemoveDailyNoteCommand = new RelayCommand<DailyNoteEntry>(RemoveDailyNote); RemoveDailyNoteCommand = new RelayCommand<DailyNoteEntry>(RemoveDailyNote);
ModifyNotificationCommand = asyncRelayCommandFactory.Create<DailyNoteEntry>(ModifyDailyNoteNotificationAsync); ModifyNotificationCommand = asyncRelayCommandFactory.Create<DailyNoteEntry>(ModifyDailyNoteNotificationAsync);
DailyNoteVerificationCommand = asyncRelayCommandFactory.Create(VerifyDailyNoteVerificationAsync);
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -148,6 +150,11 @@ internal class DailyNoteViewModel : ObservableObject, ISupportCancellation
/// </summary> /// </summary>
public ICommand ModifyNotificationCommand { get; } public ICommand ModifyNotificationCommand { get; }
/// <summary>
/// 验证实时便笺命令
/// </summary>
public ICommand DailyNoteVerificationCommand { get; }
private async Task OpenUIAsync() private async Task OpenUIAsync()
{ {
UserAndRoles = await userService.GetRoleCollectionAsync().ConfigureAwait(true); UserAndRoles = await userService.GetRoleCollectionAsync().ConfigureAwait(true);
@@ -194,4 +201,17 @@ internal class DailyNoteViewModel : ObservableObject, ISupportCancellation
appDbContext.DailyNotes.UpdateAndSave(entry); appDbContext.DailyNotes.UpdateAndSave(entry);
} }
} }
private async Task VerifyDailyNoteVerificationAsync()
{
if (userService.Current != null && userService.Current.SelectedUserGameRole != null)
{
MainWindow mainWindow = Ioc.Default.GetRequiredService<MainWindow>();
await new DailyNoteVerificationDialog(mainWindow, userService.Current.Entity, userService.Current.SelectedUserGameRole).ShowAsync();
}
else
{
Ioc.Default.GetRequiredService<IInfoBarService>().Warning("请先选中账号与角色");
}
}
} }

View File

@@ -21,8 +21,8 @@ public class DynamicSecretHandler : DelegatingHandler
// https://github.com/UIGF-org/Hoyolab.Salt // https://github.com/UIGF-org/Hoyolab.Salt
public static readonly ImmutableDictionary<string, string> DynamicSecrets = new Dictionary<string, string>() public static readonly ImmutableDictionary<string, string> DynamicSecrets = new Dictionary<string, string>()
{ {
[nameof(SaltType.K2)] = "TsmyHpZg8gFAVKTtlPaL6YwMldzxZJxQ", [nameof(SaltType.K2)] = "jrU9ULHGZdM9Os3uGHOpjyRELYxby5cg",
[nameof(SaltType.LK2)] = "osgT0DljLarYxgebPPHJFjdaxPfoiHGt", [nameof(SaltType.LK2)] = "9gaxOdeeY2W9dw5x62pywhik8cxy5TIJ",
[nameof(SaltType.X4)] = "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs", [nameof(SaltType.X4)] = "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
[nameof(SaltType.X6)] = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v", [nameof(SaltType.X6)] = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
[nameof(SaltType.PROD)] = "JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS", [nameof(SaltType.PROD)] = "JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS",