#pragma once #include #include namespace pddai { // 版本检测与自动更新:走验证平台的 /check-update,下载完整包后替换自身并重启 struct UpdateInfo { bool available = false; bool forced = false; std::string currentVersion; std::string latestVersion; std::string notes; std::string downloadUrl; std::string fileHash; std::string manifestHash; // 服务端版本清单指纹,用于识别同版本号换文件 std::string entryFile; long long fileSize = 0; std::string error; }; class Update { public: // 当前 exe 的文件版本,格式化为 a.b.c static std::string CurrentVersion(); // 查询服务端最新版本;网络错误或服务端异常时 available=false 并填 error static UpdateInfo Check(); // 下载 → 校验 SHA256 → 解压(zip 包)→ 替换 exe → 启动新进程并退出。 // progress 回调传入 0~100 的进度,可能在工作线程中被调用。 static bool Apply(const UpdateInfo& info, const std::function& progress, std::string& error); }; }