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

View File

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

View File

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

View File

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

View File

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

View File

@@ -49,7 +49,21 @@ internal static class Activation
_ = sender;
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>
/// <returns>任务</returns>
private static async Task HandleActivationAsync(AppActivationArguments args)
private static async Task HandleActivationAsync(AppActivationArguments args, bool isRedirected)
{
if (ActivateSemaphore.CurrentCount > 0)
{
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.TryGetProtocolActivatedUri(out Uri? uri))
{
await HandleUrlActivationAsync(uri).ConfigureAwait(false);
await HandleUrlActivationAsync(uri, isRedirected).ConfigureAwait(false);
}
}
else if (args.Kind == ExtendedActivationKind.Launch)
@@ -131,7 +145,7 @@ internal static class Activation
.SafeForget();
}
private static async Task HandleUrlActivationAsync(Uri uri)
private static async Task HandleUrlActivationAsync(Uri uri, bool isRedirected)
{
UriBuilder builder = new(uri);
@@ -144,21 +158,22 @@ internal static class Activation
case "achievement":
{
await WaitMainWindowAsync().ConfigureAwait(false);
await HandleAchievementActionAsync(action, parameter).ConfigureAwait(false);
await HandleAchievementActionAsync(action, parameter, isRedirected).ConfigureAwait(false);
break;
}
case "dailynote":
{
await HandleDailyNoteActionAsync(action, parameter).ConfigureAwait(false);
await HandleDailyNoteActionAsync(action, parameter, isRedirected).ConfigureAwait(false);
break;
}
}
}
private static async Task HandleAchievementActionAsync(string action, string parameter)
private static async Task HandleAchievementActionAsync(string action, string parameter, bool isRedirected)
{
_ = parameter;
_ = isRedirected;
switch (action)
{
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;
switch (action)
@@ -186,6 +201,14 @@ internal static class Activation
.GetRequiredService<IDailyNoteService>()
.RefreshDailyNotesAsync(true)
.ConfigureAwait(false);
// Check if it's redirected.
if (!isRedirected)
{
// It's a direct open process, should exit immediately.
Environment.Exit(0);
}
break;
}
}

View File

@@ -19,14 +19,13 @@ internal static class AppInstanceExtension
/// </summary>
/// <param name="appInstance">app实例</param>
/// <param name="args">参数</param>
[SuppressMessage("", "VSTHRD002")]
[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);
Task.Run(() =>
HANDLE redirectEventHandle = UnsafeCreateEvent();
Task.Run(async () =>
{
appInstance.RedirectActivationToAsync(args).AsTask().Wait();
await appInstance.RedirectActivationToAsync(args);
SetEvent(redirectEventHandle);
});
@@ -35,4 +34,9 @@ internal static class AppInstanceExtension
// non-blocking
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;
}
}
/// <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)
: 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)
{

View File

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

View File

@@ -5,7 +5,9 @@
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<RootNamespace>Snap.Hutao</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platform>x64</Platform>
<Platforms>x64</Platforms>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
@@ -153,7 +155,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<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>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View File

@@ -50,9 +50,6 @@ public sealed partial class DailyNoteVerificationDialog : ContentDialog
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
dailyNoteJsInterface = new(coreWebView2, scope.ServiceProvider);
#if DEBUG
coreWebView2.OpenDevToolsWindow();
#endif
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}");
}

View File

@@ -49,10 +49,6 @@ public sealed partial class SignInWebViewDialog : ContentDialog
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
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");
}
@@ -61,4 +57,4 @@ public sealed partial class SignInWebViewDialog : ContentDialog
signInJsInterface = null;
scope.Dispose();
}
}
}

View File

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

View File

@@ -11,6 +11,7 @@ using Snap.Hutao.Factory.Abstraction;
using Snap.Hutao.Model;
using Snap.Hutao.Model.Binding.User;
using Snap.Hutao.Model.Entity;
using Snap.Hutao.Service.Abstraction;
using Snap.Hutao.Service.DailyNote;
using Snap.Hutao.Service.User;
using Snap.Hutao.View.Dialog;
@@ -67,6 +68,7 @@ internal class DailyNoteViewModel : ObservableObject, ISupportCancellation
RefreshCommand = asyncRelayCommandFactory.Create(RefreshAsync);
RemoveDailyNoteCommand = new RelayCommand<DailyNoteEntry>(RemoveDailyNote);
ModifyNotificationCommand = asyncRelayCommandFactory.Create<DailyNoteEntry>(ModifyDailyNoteNotificationAsync);
DailyNoteVerificationCommand = asyncRelayCommandFactory.Create(VerifyDailyNoteVerificationAsync);
}
/// <inheritdoc/>
@@ -148,6 +150,11 @@ internal class DailyNoteViewModel : ObservableObject, ISupportCancellation
/// </summary>
public ICommand ModifyNotificationCommand { get; }
/// <summary>
/// 验证实时便笺命令
/// </summary>
public ICommand DailyNoteVerificationCommand { get; }
private async Task OpenUIAsync()
{
UserAndRoles = await userService.GetRoleCollectionAsync().ConfigureAwait(true);
@@ -194,4 +201,17 @@ internal class DailyNoteViewModel : ObservableObject, ISupportCancellation
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
public static readonly ImmutableDictionary<string, string> DynamicSecrets = new Dictionary<string, string>()
{
[nameof(SaltType.K2)] = "TsmyHpZg8gFAVKTtlPaL6YwMldzxZJxQ",
[nameof(SaltType.LK2)] = "osgT0DljLarYxgebPPHJFjdaxPfoiHGt",
[nameof(SaltType.K2)] = "jrU9ULHGZdM9Os3uGHOpjyRELYxby5cg",
[nameof(SaltType.LK2)] = "9gaxOdeeY2W9dw5x62pywhik8cxy5TIJ",
[nameof(SaltType.X4)] = "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
[nameof(SaltType.X6)] = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
[nameof(SaltType.PROD)] = "JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS",