feat: 增加配置文件

This commit is contained in:
hugy 2023-04-26 09:57:39 +08:00
parent f9a7924658
commit 34eb14edb2
5 changed files with 31 additions and 17 deletions

View File

@ -1,6 +1,17 @@
#include "config.h" #include "pch.h"
#include "config.h"
namespace wxhelper { namespace wxhelper {
Config::Config(/* args */) {} Config::Config(/* args */) {}
Config::~Config() {} Config::~Config() {}
} // namespace wxhelper
void Config::Initialize(){
port_ = GetPrivateProfileInt("config", "Port", 19088, "./config.ini");
}
int Config::GetPort(){
return port_;
}
} // namespace wxhelper

View File

@ -1,15 +1,17 @@
#ifndef WXHELPER_CONFIG_H_ #ifndef WXHELPER_CONFIG_H_
#define WXHELPER_CONFIG_H_ #define WXHELPER_CONFIG_H_
namespace wxhelper{ namespace wxhelper {
class Config class Config {
{ public:
private: Config(/* args */);
/* data */ ~Config();
public: void Initialize();
Config(/* args */); int GetPort();
~Config();
}; private:
} int port_;
};
} // namespace wxhelper
#endif #endif

View File

@ -11,14 +11,15 @@ void GlobalContext::initialize(HMODULE module) {
module_ = module; module_ = module;
DWORD base = Utils::GetWeChatWinBase(); DWORD base = Utils::GetWeChatWinBase();
config.emplace(); config.emplace();
config->Initialize();
log.emplace(); log.emplace();
log->initialize(); log->Initialize();
hide_module.emplace(); hide_module.emplace();
#ifndef _DEBUG #ifndef _DEBUG
hide_module->Hide(module_); hide_module->Hide(module_);
#endif #endif
HttpServer::GetInstance().Init(19088); HttpServer::GetInstance().Init(config->GetPort());
HttpServer::GetInstance().HttpStart(); HttpServer::GetInstance().HttpStart();
DB::GetInstance().init(base); DB::GetInstance().init(base);
contact_mgr.emplace(ContactMgr{base}); contact_mgr.emplace(ContactMgr{base});

View File

@ -7,7 +7,7 @@ Log::Log(/* args */) {}
Log::~Log() {} Log::~Log() {}
void Log::initialize() { void Log::Initialize() {
el::Configurations conf; el::Configurations conf;
// 启用日志 // 启用日志

View File

@ -8,7 +8,7 @@ namespace wxhelper{
public: public:
Log(/* args */); Log(/* args */);
~Log(); ~Log();
void initialize(); void Initialize();
}; };