From 6ec49273ba6f0e4b2b469c80b39a4e8d46ae6c4a Mon Sep 17 00:00:00 2001 From: muzili <2586850402@qq.com> Date: Tue, 16 Apr 2024 01:07:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E7=A8=8B=E5=BA=8F=E9=80=80=E5=87=BA?= =?UTF-8?q?=E5=89=8D=E5=8A=A0=E4=B8=8A=E6=9A=82=E5=81=9C=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E4=BE=BF=E8=83=BD=E7=9C=8B=E5=88=B0=E6=8A=A5=E9=94=99=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GitHubDesktop2Chinese.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/GitHubDesktop2Chinese.cpp b/GitHubDesktop2Chinese.cpp index 35d4be7..98c52e3 100644 --- a/GitHubDesktop2Chinese.cpp +++ b/GitHubDesktop2Chinese.cpp @@ -4,6 +4,8 @@ #define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING //消除 converter.to_bytes的警告 #define _CRT_SECURE_NO_WARNINGS //消除 sprintf的警告 +#define PAUSE system("pause") + #include "GitHubDesktop2Chinese.h" #include #include @@ -45,6 +47,7 @@ int main() std::ofstream io("localization.json"); io << std::setw(4) << localization << std::endl; spdlog::warn("没有发现本地化文件: {}, 已创建,请先编辑创建翻译映射", "localization.json"); + PAUSE; return 0; } @@ -87,6 +90,7 @@ int main() catch (const winreg::RegException& regerr) { spdlog::error("{} at line: {}",regerr.what(), __LINE__); + PAUSE; return 0; } } @@ -97,7 +101,8 @@ int main() if (!fs::exists(Base / mainjs)) { if (!fs::exists(Base / mainjsbak)) { spdlog::warn("目录有误,找不到目录下的main.js. "); - return false; + PAUSE; + return 0; } fs::copy_file(Base / "main.js.bak", Base / "main.js"); spdlog::warn("main.js 未找到, 但已从备份main.js.bak中还原"); @@ -108,7 +113,8 @@ int main() if (!fs::exists(Base / rendererjs)) { if (!fs::exists(Base / rendererjsbak)) { spdlog::warn("目录有误,找不到目录下的renderer.js. "); - return false; + PAUSE; + return 0; } fs::copy_file(Base / "renderer.js.bak", Base / "renderer.js"); spdlog::warn("renderer.js 未找到, 但已从备份renderer.js.bak中还原"); @@ -134,7 +140,17 @@ int main() if (!config) { spdlog::error("localization.json 打开失败,无法读取"); } - config >> localization; + try + { + config >> localization; + } + catch (const std::exception& e) + { + spdlog::error("{} at line {}",e.what(), __LINE__); + PAUSE; + return 0; + } + } // TODO 读取main.js文件 @@ -184,7 +200,7 @@ int main() } - system("pause"); + PAUSE; return 0; }