1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include "stdafx.h"
- #include "CVersion.h"
- CVersion::CVersion()
- {
- }
- CVersion::~CVersion()
- {
- }
- bool CVersion::Inti(std::string data)
- {
- if (data.empty())
- {
- return false;
- }
- try
- {
- nlohmann::json j = nlohmann::json::parse(data.begin(), data.end());
- if (j["code"].get<int>() == 0)
- {
- /*"version": "1.0.0",
- "appmsg" : "修复一些bug",
- "download_url" : "https://dw.appwang2.net/down/wlt1.0.apk",
- "isUpdate" : 0*/
- //
- this->appversion = j["data"]["version"].get<std::string>();
- this->appdownload = j["data"]["download_url"].get<std::string>();
- this->appmsg = j["data"]["appmsg"].get<std::string>();
- this->versionupdate = j["data"]["isUpdate"].get<int>();
- return true;
- }
- else
- {
- SStringW msg;
- msg.Format(L"当前版本号:%s", VERSION, S_CA2W(j["message"].get<std::string>().c_str(), CP_UTF8));
- this->m_error_msg = msg.GetBuffer(0);
- return false;
- }
- }
- catch (...)
- {
- this->m_error_msg = L"解析数据错误";
- return false;
- }
- return false;
- }
|