mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix game account attach uid crash
This commit is contained in:
@@ -88,10 +88,13 @@ internal sealed partial class GameAccountService : IGameAccountService
|
||||
return RegistryInterop.Set(account);
|
||||
}
|
||||
|
||||
public void AttachGameAccountToUid(GameAccount gameAccount, string uid)
|
||||
public async ValueTask AttachGameAccountToUidAsync(GameAccount gameAccount, string uid)
|
||||
{
|
||||
gameAccount.UpdateAttachUid(uid);
|
||||
await taskContext.SwitchToBackgroundAsync();
|
||||
gameDbService.UpdateGameAccount(gameAccount);
|
||||
|
||||
await taskContext.SwitchToMainThreadAsync();
|
||||
gameAccount.UpdateAttachUid(uid);
|
||||
}
|
||||
|
||||
public async ValueTask ModifyGameAccountAsync(GameAccount gameAccount)
|
||||
|
||||
@@ -11,7 +11,7 @@ internal interface IGameAccountService
|
||||
{
|
||||
ObservableReorderableDbCollection<GameAccount> GameAccountCollection { get; }
|
||||
|
||||
void AttachGameAccountToUid(GameAccount gameAccount, string uid);
|
||||
ValueTask AttachGameAccountToUidAsync(GameAccount gameAccount, string uid);
|
||||
|
||||
GameAccount? DetectCurrentGameAccount(SchemeType schemeType);
|
||||
|
||||
|
||||
@@ -27,15 +27,19 @@ internal sealed partial class GameConfigurationFileService : IGameConfigurationF
|
||||
string serverCacheFolder = runtimeOptions.GetDataFolderServerCacheFolder();
|
||||
string source = Path.Combine(serverCacheFolder, ConfigurationFileName);
|
||||
|
||||
if (File.Exists(source))
|
||||
if (!File.Exists(source))
|
||||
{
|
||||
string? directory = Path.GetDirectoryName(destination);
|
||||
if (string.IsNullOrEmpty(directory) || !Directory.Exists(directory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
File.Copy(source, destination, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// If target directory does not exist, do not copy the file
|
||||
// This often means user has moved the game folder away.
|
||||
string? directory = Path.GetDirectoryName(destination);
|
||||
if (string.IsNullOrEmpty(directory) || !Directory.Exists(directory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
File.Copy(source, destination, true);
|
||||
}
|
||||
}
|
||||
@@ -54,9 +54,9 @@ internal sealed partial class GameServiceFacade : IGameServiceFacade
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void AttachGameAccountToUid(GameAccount gameAccount, string uid)
|
||||
public ValueTask AttachGameAccountToUidAsync(GameAccount gameAccount, string uid)
|
||||
{
|
||||
gameAccountService.AttachGameAccountToUid(gameAccount, uid);
|
||||
return gameAccountService.AttachGameAccountToUidAsync(gameAccount, uid);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -25,7 +25,7 @@ internal interface IGameServiceFacade
|
||||
/// </summary>
|
||||
/// <param name="gameAccount">游戏内账号</param>
|
||||
/// <param name="uid">uid</param>
|
||||
void AttachGameAccountToUid(GameAccount gameAccount, string uid);
|
||||
ValueTask AttachGameAccountToUidAsync(GameAccount gameAccount, string uid);
|
||||
|
||||
ValueTask<GameAccount?> DetectGameAccountAsync(SchemeType scheme);
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
Command="{Binding NavigateCommand}"
|
||||
Content="{StaticResource FontIconContentSetting}"
|
||||
FontFamily="{StaticResource SymbolThemeFontFamily}"
|
||||
Style="{ThemeResource ButtonRevealStyle}"
|
||||
ToolTipService.ToolTip="{shuxm:ResourceString Name=ViewPageHomeLaunchGameSettingAction}"/>
|
||||
<StackPanel
|
||||
Grid.Row="2"
|
||||
|
||||
@@ -249,7 +249,7 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView
|
||||
|
||||
if (await userService.GetCurrentUidAsync().ConfigureAwait(false) is { } uid)
|
||||
{
|
||||
gameService.AttachGameAccountToUid(gameAccount, uid);
|
||||
await gameService.AttachGameAccountToUidAsync(gameAccount, uid).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user