mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-11 14:33:04 +00:00
feature sentry report to server use log module.
This commit is contained in:
@@ -100,8 +100,8 @@ namespace common
|
||||
}
|
||||
nlohmann::json json_data;
|
||||
json_file >> json_data;
|
||||
std::string str_version = json_data["version"];
|
||||
std::string str_build_number = json_data["build_number"];
|
||||
std::string str_version = json_data.value("version", "");
|
||||
std::string str_build_number = json_data.value("build_number", "");
|
||||
|
||||
std::string flutter_version = std::string("flutter_version: ") + str_version + std::string(" ") + std::string("build_number: ") +
|
||||
str_build_number;
|
||||
@@ -109,4 +109,73 @@ namespace common
|
||||
return flutter_version;
|
||||
}
|
||||
|
||||
|
||||
std::string getLocalArea()
|
||||
{
|
||||
std::string localArea = "";
|
||||
std::string cfgfile = "";
|
||||
#ifdef _WIN32
|
||||
wchar_t appDataPath[MAX_PATH] = {0};
|
||||
auto hr = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath);
|
||||
char* path = new char[MAX_PATH];
|
||||
size_t pathLength;
|
||||
wcstombs_s(&pathLength, path, MAX_PATH, appDataPath, MAX_PATH);
|
||||
std::string filePath = path;
|
||||
cfgfile = filePath + "\\" + std::string("Snapmaker_Orca\\Snapmaker_Orca.conf");
|
||||
#elif __APPLE__
|
||||
const char* home_env = getenv("HOME");
|
||||
cfgfile = home_env;
|
||||
cfgfile = versionFilePath + "/Library/Application Support/Snapmaker_Orca/Snapmaker_Orca.conf";
|
||||
#else
|
||||
|
||||
#endif
|
||||
std::ifstream json_file(cfgfile);
|
||||
if (!json_file.is_open()) {
|
||||
std::ifstream json_file(cfgfile);
|
||||
return "";
|
||||
}
|
||||
|
||||
nlohmann::json json_data;
|
||||
json_file >> json_data;
|
||||
|
||||
auto dataObj = json_data.value("app", nlohmann::json::object());
|
||||
localArea = dataObj.value("region", "");
|
||||
|
||||
return localArea;
|
||||
}
|
||||
|
||||
std::string getLanguage()
|
||||
{
|
||||
std::string localLanguage = "";
|
||||
|
||||
std::string cfgfile = "";
|
||||
#ifdef _WIN32
|
||||
wchar_t appDataPath[MAX_PATH] = {0};
|
||||
auto hr = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath);
|
||||
char* path = new char[MAX_PATH];
|
||||
size_t pathLength;
|
||||
wcstombs_s(&pathLength, path, MAX_PATH, appDataPath, MAX_PATH);
|
||||
std::string filePath = path;
|
||||
cfgfile = filePath + "\\" + std::string("Snapmaker_Orca\\Snapmaker_Orca.conf");
|
||||
#elif __APPLE__
|
||||
const char* home_env = getenv("HOME");
|
||||
cfgfile = home_env;
|
||||
cfgfile = versionFilePath + "/Library/Application Support/Snapmaker_Orca/Snapmaker_Orca.conf";
|
||||
#else
|
||||
|
||||
#endif
|
||||
std::ifstream json_file(cfgfile);
|
||||
if (!json_file.is_open()) {
|
||||
std::ifstream json_file(cfgfile);
|
||||
return "";
|
||||
}
|
||||
|
||||
nlohmann::json json_data;
|
||||
json_file >> json_data;
|
||||
|
||||
auto dataObj = json_data.value("app", nlohmann::json::object());
|
||||
localLanguage = dataObj.value("language", "");
|
||||
|
||||
return localLanguage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user