fix:修正win下编译和显示问题。

This commit is contained in:
taynpg 2025-01-21 14:47:42 +08:00
parent 44735dc387
commit 3356ceee67
2 changed files with 19 additions and 0 deletions

View File

@ -5,6 +5,15 @@
#include <iostream> #include <iostream>
#include <regex> #include <regex>
#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
#endif
std::shared_ptr<spdlog::logger> g_Logger = nullptr; std::shared_ptr<spdlog::logger> g_Logger = nullptr;
std::shared_ptr<CServerConfig> g_Config = nullptr; std::shared_ptr<CServerConfig> g_Config = nullptr;
@ -85,6 +94,15 @@ bool exec_cmd(const CmdParam& param, bool& run)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode;
GetConsoleMode(hConsole, &mode);
mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(hConsole, mode);
#endif
g_Config = std::make_shared<CServerConfig>(); g_Config = std::make_shared<CServerConfig>();
if (!g_Config->baseInit()) { if (!g_Config->baseInit()) {
return -1; return -1;

View File

@ -4,6 +4,7 @@
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include <iomanip> #include <iomanip>
#include <sstream>
#include <spdlog/fmt/bundled/color.h> #include <spdlog/fmt/bundled/color.h>
#include <spdlog/fmt/fmt.h> #include <spdlog/fmt/fmt.h>
#include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/rotating_file_sink.h>