|
@@ -83,12 +83,16 @@ void CManageNetWork::ThreadFun_login(LPARAM lParam)
|
|
|
msg = m_base_curl->GetLastErrorW();
|
|
|
}
|
|
|
|
|
|
- if (!CApp::getSingletonPtr()->DataToUserInfo(data))
|
|
|
+ if (!data.empty())
|
|
|
{
|
|
|
- code = -1;
|
|
|
- msg = CApp::getSingletonPtr()->GetUserinfo()->GetLastErrorW();
|
|
|
+ if (!CApp::getSingletonPtr()->DataToUserInfo(data))
|
|
|
+ {
|
|
|
+ code = -1;
|
|
|
+ msg = CApp::getSingletonPtr()->GetUserinfo()->GetLastErrorW();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
DataToFile();
|
|
|
|
|
|
EventLogin* pEvt = new EventLogin(nullptr);
|
|
@@ -101,9 +105,12 @@ void CManageNetWork::ThreadFun_login(LPARAM lParam)
|
|
|
void CManageNetWork::LoadFileToData() {
|
|
|
FileOperate f;
|
|
|
std::string path = std::filesystem::current_path().string();
|
|
|
- if (f.open(path + "\\user.txt", std::fstream::in | std::fstream::out | std::fstream::app)) {
|
|
|
+ if (f.open(path + "\\user.json", std::fstream::in | std::fstream::out | std::fstream::app)) {
|
|
|
std::string data = f.readAll();
|
|
|
-
|
|
|
+ if (data.empty())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
nlohmann::json j3 = nlohmann::json::parse(data.begin(), data.end());
|
|
|
this->m_username = j3["username"].get<std::string>().c_str();
|
|
|
this->m_password = j3["password"].get<std::string>().c_str();
|
|
@@ -125,9 +132,9 @@ void CManageNetWork::DataToFile()
|
|
|
|
|
|
std::string path = std::filesystem::current_path().string();
|
|
|
|
|
|
- f.create(path + "\\user.txt");
|
|
|
+ f.create(path + "\\user.json");
|
|
|
|
|
|
- if (f.open(path + "\\user.txt", std::fstream::in | std::fstream::out | std::fstream::app)) {
|
|
|
+ if (f.open(path + "\\user.json", std::fstream::in | std::fstream::out | std::fstream::app)) {
|
|
|
f.write(str);
|
|
|
}
|
|
|
|