mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
auto select existed account when detecting
This commit is contained in:
@@ -281,7 +281,7 @@ internal sealed partial class GameService : IGameService
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async ValueTask DetectGameAccountAsync()
|
||||
public async ValueTask<GameAccount?> DetectGameAccountAsync()
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(gameAccounts);
|
||||
|
||||
@@ -318,7 +318,11 @@ internal sealed partial class GameService : IGameService
|
||||
gameAccounts.Add(account);
|
||||
}
|
||||
}
|
||||
|
||||
return account;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -26,11 +26,7 @@ internal interface IGameService
|
||||
/// <param name="uid">uid</param>
|
||||
void AttachGameAccountToUid(GameAccount gameAccount, string uid);
|
||||
|
||||
/// <summary>
|
||||
/// 检测并尝试添加游戏内账户
|
||||
/// </summary>
|
||||
/// <returns>任务</returns>
|
||||
ValueTask DetectGameAccountAsync();
|
||||
ValueTask<GameAccount?> DetectGameAccountAsync();
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取游戏路径
|
||||
|
||||
@@ -236,7 +236,15 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel
|
||||
{
|
||||
try
|
||||
{
|
||||
await gameService.DetectGameAccountAsync().ConfigureAwait(false);
|
||||
GameAccount? account = await gameService.DetectGameAccountAsync().ConfigureAwait(false);
|
||||
|
||||
// If user canceled the operation, the return is null,
|
||||
// and thus we should not set SelectedAccount
|
||||
if (account is not null)
|
||||
{
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
SelectedGameAccount = account;
|
||||
}
|
||||
}
|
||||
catch (UserdataCorruptedException ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user