mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 02:55:38 +08:00
chore: 提取 ResourceReload 方法
This commit is contained in:
@@ -1612,14 +1612,7 @@ namespace MaaWpfGui.Main
|
||||
return;
|
||||
}
|
||||
|
||||
var ret = await ResourceUpdater.CheckAndDownloadResourceUpdate();
|
||||
if (ret == VersionUpdateViewModel.CheckUpdateRetT.OnlyGameResourceUpdated)
|
||||
{
|
||||
Instances.AsstProxy.LoadResource();
|
||||
DataHelper.Reload();
|
||||
SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate();
|
||||
ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated"));
|
||||
}
|
||||
await ResourceUpdater.ResourceUpdateAndReloadAsync();
|
||||
});
|
||||
break;
|
||||
|
||||
|
||||
@@ -291,6 +291,28 @@ namespace MaaWpfGui.Models
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static async Task ResourceUpdateAndReloadAsync()
|
||||
{
|
||||
if (SettingsViewModel.VersionUpdateSettings.IsCheckingForUpdates)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ret = await CheckAndDownloadResourceUpdate();
|
||||
if (ret == CheckUpdateRetT.OnlyGameResourceUpdated)
|
||||
{
|
||||
ResourceReload();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResourceReload()
|
||||
{
|
||||
Instances.AsstProxy.LoadResource();
|
||||
DataHelper.Reload();
|
||||
SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate();
|
||||
ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated"));
|
||||
}
|
||||
|
||||
private static async Task<bool> DownloadFullPackageAsync(string url, string saveTo)
|
||||
{
|
||||
using var response = await Instances.HttpService.GetAsync(new Uri(url));
|
||||
|
||||
@@ -474,13 +474,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
_ = Instances.VersionUpdateViewModel.AskToRestart();
|
||||
}
|
||||
|
||||
if (await ResourceUpdater.CheckAndDownloadResourceUpdate() == VersionUpdateViewModel.CheckUpdateRetT.OnlyGameResourceUpdated)
|
||||
{
|
||||
Instances.AsstProxy.LoadResource();
|
||||
DataHelper.Reload();
|
||||
SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate();
|
||||
ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated"));
|
||||
}
|
||||
await ResourceUpdater.ResourceUpdateAndReloadAsync();
|
||||
|
||||
_isCheckingForUpdates = false;
|
||||
});
|
||||
|
||||
@@ -488,14 +488,7 @@ public class VersionUpdateViewModel : Screen
|
||||
_ = AskToRestart();
|
||||
}
|
||||
|
||||
var ret2 = await ResourceUpdater.CheckAndDownloadResourceUpdate();
|
||||
if (ret2 == CheckUpdateRetT.OnlyGameResourceUpdated)
|
||||
{
|
||||
Instances.AsstProxy.LoadResource();
|
||||
DataHelper.Reload();
|
||||
SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate();
|
||||
ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated"));
|
||||
}
|
||||
await ResourceUpdater.ResourceUpdateAndReloadAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -462,10 +462,7 @@ public class VersionUpdateSettingsUserControlModel : PropertyChangedBase
|
||||
|
||||
if (success)
|
||||
{
|
||||
Instances.AsstProxy.LoadResource();
|
||||
DataHelper.Reload();
|
||||
SettingsViewModel.VersionUpdateSettings.ResourceInfoUpdate();
|
||||
ToastNotification.ShowDirect(LocalizationHelper.GetString("GameResourceUpdated"));
|
||||
ResourceUpdater.ResourceReload();
|
||||
}
|
||||
|
||||
IsCheckingForUpdates = false;
|
||||
|
||||
Reference in New Issue
Block a user