mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix detect game account crash
This commit is contained in:
@@ -22,7 +22,7 @@ internal interface IInfoBarService
|
||||
/// </summary>
|
||||
/// <param name="message">消息</param>
|
||||
/// <param name="delay">关闭延迟</param>
|
||||
void Error(string message, int delay = 60000);
|
||||
void Error(string message, int delay = 30000);
|
||||
|
||||
/// <summary>
|
||||
/// 显示错误消息
|
||||
@@ -30,14 +30,14 @@ internal interface IInfoBarService
|
||||
/// <param name="title">标题</param>
|
||||
/// <param name="message">消息</param>
|
||||
/// <param name="delay">关闭延迟</param>
|
||||
void Error(string title, string message, int delay = 60000);
|
||||
void Error(string title, string message, int delay = 30000);
|
||||
|
||||
/// <summary>
|
||||
/// 显示错误消息
|
||||
/// </summary>
|
||||
/// <param name="exception">异常</param>
|
||||
/// <param name="delay">关闭延迟</param>
|
||||
void Error(Exception exception, int delay = 60000);
|
||||
void Error(Exception exception, int delay = 30000);
|
||||
|
||||
/// <summary>
|
||||
/// 显示错误消息
|
||||
@@ -45,7 +45,7 @@ internal interface IInfoBarService
|
||||
/// <param name="exception">异常</param>
|
||||
/// <param name="title">标题</param>
|
||||
/// <param name="delay">关闭延迟</param>
|
||||
void Error(Exception exception, string title, int delay = 60000);
|
||||
void Error(Exception exception, string title, int delay = 30000);
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示信息
|
||||
@@ -82,7 +82,7 @@ internal interface IInfoBarService
|
||||
/// </summary>
|
||||
/// <param name="message">消息</param>
|
||||
/// <param name="delay">关闭延迟</param>
|
||||
void Warning(string message, int delay = 30000);
|
||||
void Warning(string message, int delay = 15000);
|
||||
|
||||
/// <summary>
|
||||
/// 显示警告信息
|
||||
@@ -90,5 +90,5 @@ internal interface IInfoBarService
|
||||
/// <param name="title">标题</param>
|
||||
/// <param name="message">消息</param>
|
||||
/// <param name="delay">关闭延迟</param>
|
||||
void Warning(string title, string message, int delay = 30000);
|
||||
void Warning(string title, string message, int delay = 15000);
|
||||
}
|
||||
|
||||
@@ -149,6 +149,10 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel
|
||||
SelectedGameAccount ??= gameService.DetectCurrentGameAccount();
|
||||
}
|
||||
}
|
||||
catch (UserdataCorruptedException ex)
|
||||
{
|
||||
infoBarService.Error(ex);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Core.ExceptionService;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Service.Game;
|
||||
using Snap.Hutao.Service.Notification;
|
||||
@@ -17,6 +18,7 @@ internal sealed partial class LaunchGameViewModelSlim : Abstraction.ViewModelSli
|
||||
{
|
||||
private readonly IGameService gameService;
|
||||
private readonly ITaskContext taskContext;
|
||||
private readonly IInfoBarService infoBarService;
|
||||
|
||||
private ObservableCollection<GameAccount>? gameAccounts;
|
||||
private GameAccount? selectedGameAccount;
|
||||
@@ -38,8 +40,15 @@ internal sealed partial class LaunchGameViewModelSlim : Abstraction.ViewModelSli
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
GameAccounts = accounts;
|
||||
|
||||
// Try set to the current account.
|
||||
SelectedGameAccount ??= gameService.DetectCurrentGameAccount();
|
||||
try
|
||||
{
|
||||
// Try set to the current account.
|
||||
SelectedGameAccount ??= gameService.DetectCurrentGameAccount();
|
||||
}
|
||||
catch (UserdataCorruptedException ex)
|
||||
{
|
||||
infoBarService.Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[Command("LaunchCommand", AllowConcurrentExecutions = true)]
|
||||
|
||||
Reference in New Issue
Block a user