mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
feat: 初步实现保存配置文件
This commit is contained in:
parent
0f54661f22
commit
ba65e286ff
6 changed files with 54 additions and 5 deletions
|
|
@ -7,6 +7,8 @@
|
|||
#include "Utils.h"
|
||||
#include "StrUtils.h"
|
||||
#include "Logger.h"
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/prettywriter.h>
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Windows::Foundation;
|
||||
|
|
@ -60,8 +62,23 @@ bool Settings::Initialize() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Settings::Save() {
|
||||
|
||||
bool Settings::Save() {
|
||||
std::wstring configPath = GetConfigPath(_isPortableMode);
|
||||
if (!Utils::CreateDirRecursive(configPath.substr(0, configPath.find_last_of(L'\\')))) {
|
||||
Logger::Get().Error("创建配置文件路径失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
rapidjson::StringBuffer json;
|
||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(json);
|
||||
writer.StartObject();
|
||||
writer.Key("theme");
|
||||
writer.Uint(_theme);
|
||||
writer.EndObject();
|
||||
|
||||
Utils::WriteTextFile(configPath.c_str(), json.GetString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue