diff --git a/BetterGenshinImpact/BetterGenshinImpact.csproj b/BetterGenshinImpact/BetterGenshinImpact.csproj
index 2805db08..9e81a682 100644
--- a/BetterGenshinImpact/BetterGenshinImpact.csproj
+++ b/BetterGenshinImpact/BetterGenshinImpact.csproj
@@ -10,7 +10,7 @@
true
Assets\Images\logo.ico
BetterGI
- 0.39.7
+ 0.40.0
x64
embedded
diff --git a/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs b/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs
index dcbb3988..2ba43d9c 100644
--- a/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs
+++ b/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs
@@ -102,12 +102,12 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
{
// 预热OCR
await OcrPreheating();
-
+
if (Environment.GetCommandLineArgs().Length > 1)
{
return;
}
-
+
// 自动处理目录配置
await Patch1();
@@ -158,19 +158,28 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
*/
private async Task Patch1()
{
- if (Directory.Exists(Global.Absolute("BetterGI"))
- // && File.Exists(Global.Absolute("BetterGI/BetterGI.exe"))
- && Directory.Exists(Global.Absolute("BetterGI/User"))
+ var embeddedPath = Global.Absolute("BetterGI");
+ var embeddedUserPath = Global.Absolute("BetterGI/User");
+ var exePath = Global.Absolute("BetterGI/BetterGI.exe");
+ if (Directory.Exists(embeddedPath)
+ && File.Exists(exePath)
+ && Directory.Exists(embeddedUserPath)
)
{
- var res = await MessageBox.ShowAsync("检测到旧的 BetterGI 配置,是否迁移配置并清理旧目录?", "BetterGI", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Question);
- if (res == System.Windows.MessageBoxResult.Yes)
+ var fileVersionInfo = FileVersionInfo.GetVersionInfo(exePath);
+ // 低版本才需要迁移
+ if (fileVersionInfo.FileVersion != null && !Global.IsNewVersion(fileVersionInfo.FileVersion))
{
- var dir = Global.Absolute("BetterGI/User");
- // 迁移配置,拷贝整个目录并覆盖
- DirectoryHelper.CopyDirectory(dir, Global.Absolute("User"));
- // 删除旧目录
- DirectoryHelper.DeleteDirectoryRecursively(Global.Absolute("BetterGI"));
+ var res = await MessageBox.ShowAsync("检测到旧的 BetterGI 配置,是否迁移配置并清理旧目录?", "BetterGI", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Question);
+ if (res == System.Windows.MessageBoxResult.Yes)
+ {
+ // 迁移配置,拷贝整个目录并覆盖
+ DirectoryHelper.CopyDirectory(embeddedUserPath, Global.Absolute("User"));
+ // 删除旧目录
+ DirectoryHelper.DeleteReadOnlyDirectory(embeddedPath);
+ await MessageBox.InformationAsync("迁移配置成功, 软件将自动退出,请手动重新启动 BetterGI!");
+ Application.Current.Shutdown();
+ }
}
}
}