improve:自动更新

This commit is contained in:
2026-02-18 22:03:30 +08:00
parent c838b9d077
commit 681b674eb2
+25 -1
View File
@@ -1341,13 +1341,25 @@ namespace Ink_Canvas.Helpers
}
}
// 安装新版本应用 - 优化版本,不使用命令行
// 安装新版本应用
public static void InstallNewVersionApp(string version, bool isInSilence)
{
bool wasProcessProtectionEnabled = false;
try
{
wasProcessProtectionEnabled = ProcessProtectionManager.Enabled;
}
catch
{
}
try
{
App.IsUpdateInstalling = true;
if (wasProcessProtectionEnabled)
{
try { ProcessProtectionManager.SetEnabled(false); } catch { }
}
// 在更新前备份设置文件
try
@@ -1509,6 +1521,18 @@ namespace Ink_Canvas.Helpers
LogHelper.WriteLogToFile($"AutoUpdate | 内部异常: {ex.InnerException.Message}", LogHelper.LogType.Error);
}
}
finally
{
// 确保无论更新成功还是失败,都恢复标志位和进程保护状态
App.IsUpdateInstalling = false;
try
{
ProcessProtectionManager.SetEnabled(wasProcessProtectionEnabled);
}
catch
{
}
}
}
// 处理更新模式的启动参数