CVersion.cpp 858 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "stdafx.h"
  2. #include "CVersion.h"
  3. CVersion::CVersion()
  4. {
  5. }
  6. CVersion::~CVersion()
  7. {
  8. }
  9. bool CVersion::Inti(std::string data)
  10. {
  11. if (data.empty())
  12. {
  13. return false;
  14. }
  15. try
  16. {
  17. nlohmann::json j = nlohmann::json::parse(data.begin(), data.end());
  18. if (j["ret"].get<int>() == 1)
  19. {
  20. //
  21. this->appversion = j["data"]["appversion"].get<std::string>();
  22. this->appdownload = j["data"]["appdownload"].get<std::string>();
  23. this->appmsg = j["data"]["appmsg"].get<std::string>();
  24. this->versionupdate = j["data"]["versionupdate"].get<int>();
  25. return true;
  26. }
  27. else
  28. {
  29. SStringW msg;
  30. msg.Format(L"当前版本号:%s", VERSION, S_CA2W(j["msg"].get<std::string>().c_str(), CP_UTF8));
  31. this->m_error_msg = msg.GetBuffer(0);
  32. return false;
  33. }
  34. }
  35. catch (...)
  36. {
  37. this->m_error_msg = L"解析数据错误";
  38. return false;
  39. }
  40. return false;
  41. }