diff --git a/3rdparty/WinCommander.cpp b/3rdparty/WinCommander.cpp index 7d2245b..fe2fa02 100644 --- a/3rdparty/WinCommander.cpp +++ b/3rdparty/WinCommander.cpp @@ -44,7 +44,8 @@ Returns the return value of the executed command */ uint WinCommander::runProcessElevated(const QString &path, const QStringList ¶meters, - const QString &workingDir, bool aWait) { + const QString &workingDir, + bool hide, bool aWait) { uint result = 0; #ifdef Q_OS_WIN @@ -75,7 +76,7 @@ uint WinCommander::runProcessElevated(const QString &path, shex.lpParameters = pszParameters; shex.lpDirectory = pszDirectory; // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow - shex.nShow = SW_SHOWMINIMIZED; + shex.nShow = hide ? SW_HIDE : SW_SHOWMINIMIZED; ShellExecuteEx(&shex); if (shex.hProcess) @@ -109,6 +110,6 @@ execution or wait for the exit of the launched process Returns the return value of the executed command */ uint WinCommander::runProcessElevated(const QString &path, const QString ¶meters, const QString &workingDir, - bool aWait) { - return runProcessElevated(path, QStringList() << parameters, workingDir, aWait); + bool hide, bool aWait) { + return runProcessElevated(path, QStringList() << parameters, workingDir, hide, aWait); } diff --git a/3rdparty/WinCommander.hpp b/3rdparty/WinCommander.hpp index 0b6c728..13532db 100644 --- a/3rdparty/WinCommander.hpp +++ b/3rdparty/WinCommander.hpp @@ -31,12 +31,12 @@ public: static uint runProcessElevated(const QString &path, const QStringList ¶meters = QStringList(), const QString &workingDir = QString(), - bool aWait = true); + bool hide = false, bool aWait = true); static uint runProcessElevated(const QString &path, const QString ¶meters = QString(), const QString &workingDir = QString(), - bool aWait = true); + bool hide = false, bool aWait = true); }; #endif // WINCOMMANDER_H \ No newline at end of file diff --git a/main/NekoRay.cpp b/main/NekoRay.cpp index b01c333..a426c27 100644 --- a/main/NekoRay.cpp +++ b/main/NekoRay.cpp @@ -53,6 +53,7 @@ namespace NekoRay { _add(new configItem("vpn_impl", &vpn_implementation, itemType::integer)); _add(new configItem("vpn_mtu", &vpn_mtu, itemType::integer)); _add(new configItem("vpn_ipv6", &vpn_ipv6, itemType::boolean)); + _add(new configItem("vpn_hide_console", &vpn_hide_consloe, itemType::boolean)); _add(new configItem("check_include_pre", &check_include_pre, itemType::boolean)); } diff --git a/main/NekoRay_DataStore.hpp b/main/NekoRay_DataStore.hpp index 1b3dd1b..eff8b6b 100644 --- a/main/NekoRay_DataStore.hpp +++ b/main/NekoRay_DataStore.hpp @@ -106,6 +106,7 @@ namespace NekoRay { int vpn_implementation = 0; int vpn_mtu = 9000; bool vpn_ipv6 = false; + bool vpn_hide_consloe = false; // Hotkey QString hotkey_mainwindow = ""; diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 852692d..192e139 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -482,6 +482,10 @@ VPN Enable IPv6 启用 VPN IPv6 + + Hide Console + 隐藏控制台 + EditChain diff --git a/ui/dialog_manage_routes.cpp b/ui/dialog_manage_routes.cpp index 7915f8f..9b9d9b6 100644 --- a/ui/dialog_manage_routes.cpp +++ b/ui/dialog_manage_routes.cpp @@ -44,6 +44,10 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : ui->vpn_implementation->setCurrentIndex(NekoRay::dataStore->vpn_implementation); ui->vpn_mtu->setCurrentText(Int2String(NekoRay::dataStore->vpn_mtu)); ui->vpn_ipv6->setChecked(NekoRay::dataStore->vpn_ipv6); + ui->hide_console->setChecked(NekoRay::dataStore->vpn_hide_consloe); +#ifndef Q_OS_WIN + ui->hide_console->setVisible(false); +#endif // #ifdef Q_OS_WIN ui->vpn_implementation->setItemText(0, Preset::SingBox::VpnImplementation[0]); @@ -122,6 +126,7 @@ void DialogManageRoutes::accept() { NekoRay::dataStore->fake_dns = fakedns; NekoRay::dataStore->vpn_mtu = mtu; NekoRay::dataStore->vpn_ipv6 = ipv6; + NekoRay::dataStore->vpn_hide_consloe = ui->hide_console->isChecked(); // bool routeChanged = false; if (NekoRay::dataStore->active_routing != active_routing) routeChanged = true; diff --git a/ui/dialog_manage_routes.ui b/ui/dialog_manage_routes.ui index f3a3c1e..9b2124d 100644 --- a/ui/dialog_manage_routes.ui +++ b/ui/dialog_manage_routes.ui @@ -175,6 +175,19 @@ + + + + + 0 + 0 + + + + Hide Console + + + diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 327fa4d..e724ed1 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -1405,7 +1405,10 @@ bool MainWindow::StartVPNProcess() { runOnNewThread([=] { vpn_pid = 1; //TODO get pid? WinCommander::runProcessElevated(QApplication::applicationDirPath() + "/sing-box.exe", - {"--disable-color", "run", "-c", configPath}); // blocking + {"--disable-color", "run", "-c", configPath}, + "", + NekoRay::dataStore->vpn_hide_consloe + ); // blocking vpn_pid = 0; runOnUiThread([=] { neko_set_spmode(NekoRay::SystemProxyMode::DISABLE);