diff --git a/src/config.cc b/src/config.cc index 2f86227..171ff88 100644 --- a/src/config.cc +++ b/src/config.cc @@ -1,6 +1,17 @@ -#include "config.h" +#include "pch.h" +#include "config.h" + namespace wxhelper { Config::Config(/* args */) {} Config::~Config() {} -} // namespace wxhelper \ No newline at end of file + + +void Config::Initialize(){ + port_ = GetPrivateProfileInt("config", "Port", 19088, "./config.ini"); +} +int Config::GetPort(){ + return port_; +} + + } // namespace wxhelper \ No newline at end of file diff --git a/src/config.h b/src/config.h index 5df279e..ffde254 100644 --- a/src/config.h +++ b/src/config.h @@ -1,15 +1,17 @@ -#ifndef WXHELPER_CONFIG_H_ +#ifndef WXHELPER_CONFIG_H_ #define WXHELPER_CONFIG_H_ -namespace wxhelper{ +namespace wxhelper { - class Config - { - private: - /* data */ - public: - Config(/* args */); - ~Config(); - }; -} +class Config { + public: + Config(/* args */); + ~Config(); + void Initialize(); + int GetPort(); + + private: + int port_; +}; +} // namespace wxhelper #endif \ No newline at end of file diff --git a/src/global_context.cc b/src/global_context.cc index 909973d..c711671 100644 --- a/src/global_context.cc +++ b/src/global_context.cc @@ -11,14 +11,15 @@ void GlobalContext::initialize(HMODULE module) { module_ = module; DWORD base = Utils::GetWeChatWinBase(); config.emplace(); + config->Initialize(); log.emplace(); - log->initialize(); + log->Initialize(); hide_module.emplace(); #ifndef _DEBUG hide_module->Hide(module_); #endif - HttpServer::GetInstance().Init(19088); + HttpServer::GetInstance().Init(config->GetPort()); HttpServer::GetInstance().HttpStart(); DB::GetInstance().init(base); contact_mgr.emplace(ContactMgr{base}); diff --git a/src/log.cc b/src/log.cc index 77841a8..c955235 100644 --- a/src/log.cc +++ b/src/log.cc @@ -7,7 +7,7 @@ Log::Log(/* args */) {} Log::~Log() {} -void Log::initialize() { +void Log::Initialize() { el::Configurations conf; // 启用日志 diff --git a/src/log.h b/src/log.h index ebca51a..9718263 100644 --- a/src/log.h +++ b/src/log.h @@ -8,7 +8,7 @@ namespace wxhelper{ public: Log(/* args */); ~Log(); - void initialize(); + void Initialize(); };