mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
perf: 允许无OTA包更新
This commit is contained in:
@@ -174,27 +174,6 @@ namespace MaaWpfGui.Main
|
||||
|
||||
_logger.Information("===================================");
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(".old", true);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
foreach (var file in new DirectoryInfo(".").GetFiles("*.old"))
|
||||
{
|
||||
try
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationHelper.Load();
|
||||
LocalizationHelper.Load();
|
||||
ETagCache.Load();
|
||||
@@ -335,6 +314,29 @@ namespace MaaWpfGui.Main
|
||||
Log.CloseAndFlush();
|
||||
base.OnExit(e);
|
||||
|
||||
if (!_isRestartingAfterUpdate)
|
||||
{ // 如果是更新后重启,则不删除 .old
|
||||
try
|
||||
{ // 退出时移除.old
|
||||
Directory.Delete(".old", true);
|
||||
}
|
||||
catch (Exception)
|
||||
{ // ignored
|
||||
}
|
||||
|
||||
foreach (var file in new DirectoryInfo(".").GetFiles("*.old"))
|
||||
{
|
||||
try
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!_isRestartingWithoutArgs)
|
||||
{
|
||||
return;
|
||||
@@ -385,6 +387,15 @@ namespace MaaWpfGui.Main
|
||||
Execute.OnUIThread(Application.Current.Shutdown);
|
||||
}
|
||||
|
||||
private static bool _isRestartingAfterUpdate;
|
||||
|
||||
public static void RestartAfterUpdate([CallerMemberName] string caller = "")
|
||||
{
|
||||
_isRestartingAfterUpdate = true;
|
||||
_logger.Information($"Shutdown and restart without Args, call by `{caller}`");
|
||||
Execute.OnUIThread(Application.Current.Shutdown);
|
||||
}
|
||||
|
||||
public static void Shutdown([CallerMemberName] string caller = "")
|
||||
{
|
||||
_logger.Information($"Shutdown called by `{caller}`");
|
||||
|
||||
@@ -311,7 +311,7 @@ You can cancel this popup by clicking the Settings - Issue Report link. Thank yo
|
||||
<system:String x:Key="CheckNetworking">Please check your network connection or proxy.</system:String>
|
||||
<system:String x:Key="GetReleaseNoteFailed">Failed to get release note.</system:String>
|
||||
<system:String x:Key="NewVersionIsBeingBuilt">The new version is being built, please try again later</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">A new version has been detected, but no OTA (incremental) update package is available due to the outdated version currently in use. Please download the full package and extract it into a **new** folder. Do not overwrite your existing installation folder.\nTo retain your settings, manually copy the config and data folders from the old installation to the new one.</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">A new version has been detected. Since the current version is too old, no OTA incremental update package is available. The full package will be downloaded and the folders in the update package will be removed. Please back up manually if necessary.</system:String>
|
||||
<system:String x:Key="NewVersionDownloadPreparing">Preparing to download update package……</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedTitle">Download of Update Package Failed</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedDesc">Please download the zip file manually and place it in the directory</system:String>
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
<system:String x:Key="CheckNetworking">ネットワークの接続状況とプロクシの設定を確認してください。</system:String>
|
||||
<system:String x:Key="GetReleaseNoteFailed">リリースノートの取得に失敗しました。</system:String>
|
||||
<system:String x:Key="NewVersionIsBeingBuilt">新しいバージョンの準備中です。時間をおいてからもう一度実行してください</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">新しいバージョンが検出されましたが、現在のバージョンが古いため、OTA(増分)アップデートパッケージは提供されていません。完全パッケージをダウンロードして**必ず新しいフォルダー**に解凍してください。既存のフォルダーに上書きしないでください。\n設定を引き継ぐには、元の config および data フォルダーを新しいフォルダーに手動でコピーしてください。</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">新しいバージョンが検出されました。現在のバージョンが古すぎるため、OTA増分アップデートパッケージは利用できません。パッケージ全体がダウンロードされ、アップデートパッケージ内のフォルダは削除されます。必要に応じて手動でバックアップしてください。</system:String>
|
||||
<system:String x:Key="NewVersionDownloadPreparing">アップデートパッケージのダウンロードを準備中です……</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedTitle">アップデートパッケージのダウンロードに失敗しました</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedDesc">ZIPファイルを手動でダウンロードし、ディレクトリに配置してください</system:String>
|
||||
|
||||
@@ -311,7 +311,7 @@
|
||||
<system:String x:Key="CheckNetworking">네트워크 연결이나 프록시를 확인해 주세요.</system:String>
|
||||
<system:String x:Key="GetReleaseNoteFailed">릴리즈 노트를 받아오지 못했습니다.</system:String>
|
||||
<system:String x:Key="NewVersionIsBeingBuilt">새로운 버전이 빌드되는 중입니다. 다음에 다시 시도해 주세요</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">새 버전이 감지되었지만 현재 사용 중인 버전이 오래되어 OTA(증분) 업데이트 패키지가 제공되지 않습니다. 전체 설치 패키지를 다운로드하여 **반드시 새로운 폴더**에 압축을 푸세요. 기존 폴더에 덮어쓰지 마세요.\n설정을 유지하려면 기존 설치 폴더의 config 및 data 폴더를 새 폴더로 수동으로 복사해야 합니다.</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">새 버전이 감지되었습니다. 현재 버전이 너무 오래되어 OTA 증분 업데이트 패키지를 사용할 수 없습니다. 전체 패키지가 다운로드되고 업데이트 패키지의 폴더가 제거됩니다. 필요한 경우 수동으로 백업하세요.</system:String>
|
||||
<system:String x:Key="NewVersionDownloadPreparing">업데이트 패키지 다운로드 준비 중……</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedTitle">업데이트 패키지 다운로드 실패</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedDesc">ZIP 파일을 수동으로 다운로드해 폴더 안에 놓아 주세요</system:String>
|
||||
|
||||
@@ -312,7 +312,7 @@
|
||||
<system:String x:Key="CheckNetworking">请检查网络连接或代理。</system:String>
|
||||
<system:String x:Key="GetReleaseNoteFailed">获取更新信息失败。</system:String>
|
||||
<system:String x:Key="NewVersionIsBeingBuilt">我知道你很急但你先别急.jpg</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">检测到新版本,但由于当前版本过旧,未提供可用的 OTA 增量更新包。请下载完整包并解压到新文件夹,请勿直接覆盖原文件夹。\n可将原有的 config 与 data 文件夹复制到新文件夹中,以保留原有配置。</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">检测到新版本, 由于当前版本过旧, 无可用的 OTA 增量更新包。将下载完整包并移除更新包中的文件夹, 如有需要请手动备份</system:String>
|
||||
<system:String x:Key="NewVersionDownloadPreparing">正在准备下载更新包……</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedTitle">新版本下载失败</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedDesc">请尝试手动下载后,将压缩包放到目录下_(:з」∠)_</system:String>
|
||||
|
||||
@@ -311,7 +311,7 @@
|
||||
<system:String x:Key="CheckNetworking">請檢查網絡連接或代理。</system:String>
|
||||
<system:String x:Key="GetReleaseNoteFailed">獲取更新資訊失敗。</system:String>
|
||||
<system:String x:Key="NewVersionIsBeingBuilt">我知道你很急但你先別急.jpg</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">偵測到新版本,但由於當前版本過舊,未提供可用的 OTA 增量更新包。請下載完整包並解壓至新的資料夾中,切勿覆蓋原有程式資料夾。\n若需保留設定,請將原有的 config 與 data 資料夾手動複製到新資料夾。</system:String>
|
||||
<system:String x:Key="NewVersionNoOtaPackage">偵測到新版本, 由於目前版本過舊, 無可用的 OTA 增量更新包。將下載完整包並移除更新包中的資料夾, 如有需要請手動備份</system:String>
|
||||
<system:String x:Key="NewVersionDownloadPreparing">正在準備下載更新檔……</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedTitle">新版本下載失敗</system:String>
|
||||
<system:String x:Key="NewVersionDownloadFailedDesc">請嘗試手動下載後,將壓縮檔放到目錄下_(:з」∠)_</system:String>
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
// 更新直接重启
|
||||
if (Instances.VersionUpdateViewModel.CheckAndUpdateNow())
|
||||
{
|
||||
Bootstrapper.ShutdownAndRestartWithoutArgs();
|
||||
Bootstrapper.RestartAfterUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -436,11 +436,6 @@ public class VersionUpdateViewModel : Screen
|
||||
/// NoMirrorChyanCdk
|
||||
/// </summary>
|
||||
NoMirrorChyanCdk,
|
||||
|
||||
/// <summary>
|
||||
/// 找到新版本,但没有可用的 OTA 更新包(仅有完整包)
|
||||
/// </summary>
|
||||
NewVersionNoOtaPackage,
|
||||
}
|
||||
|
||||
public enum AppUpdateSource
|
||||
@@ -557,11 +552,6 @@ public class VersionUpdateViewModel : Screen
|
||||
|
||||
var (checkRet, source) = await CheckUpdate();
|
||||
|
||||
if (checkRet == CheckUpdateRetT.NewVersionNoOtaPackage)
|
||||
{
|
||||
MessageBoxHelper.Show(LocalizationHelper.GetString("NewVersionNoOtaPackage"), icon: MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
if (checkRet != CheckUpdateRetT.OK)
|
||||
{
|
||||
return checkRet;
|
||||
@@ -987,10 +977,11 @@ public class VersionUpdateViewModel : Screen
|
||||
|
||||
if (_assetsObject == null && fullPackage != null)
|
||||
{
|
||||
// 不允许直接使用完整包,有些版本要删除文件,不走自动更新不会清理
|
||||
// _assetsObject = fullPackage;
|
||||
_assetsObject = fullPackage;
|
||||
_logger.Warning("No OTA package found, but full package found.");
|
||||
return CheckUpdateRetT.NewVersionNoOtaPackage;
|
||||
using var toast = new ToastNotification(LocalizationHelper.GetString("NewVersionNoOtaPackage"));
|
||||
toast.Show(30);
|
||||
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("NewVersionNoOtaPackage"), UiLogColor.Warning);
|
||||
}
|
||||
|
||||
return CheckUpdateRetT.OK;
|
||||
|
||||
Reference in New Issue
Block a user