diff --git a/include/configs/proxy/CustomBean.hpp b/include/configs/proxy/CustomBean.hpp index 24db72d..1670ae1 100644 --- a/include/configs/proxy/CustomBean.hpp +++ b/include/configs/proxy/CustomBean.hpp @@ -24,7 +24,7 @@ namespace NekoGui_fmt { QString DisplayType() override { if (core == "internal") { auto obj = QString2QJsonObject(config_simple); - return obj[IS_NEKO_BOX ? "type" : "protocol"].toString(); + return obj["type"].toString(); } else if (core == "internal-full") { return software_core_name + " config"; } diff --git a/include/global/NekoGui.hpp b/include/global/NekoGui.hpp index 9fd53be..3697148 100644 --- a/include/global/NekoGui.hpp +++ b/include/global/NekoGui.hpp @@ -8,8 +8,6 @@ // Switch core support namespace NekoGui { - inline int coreType = CoreType::SING_BOX; - QString FindCoreAsset(const QString &name); QString FindNekoBoxCoreRealPath(); @@ -21,7 +19,6 @@ namespace NekoGui { bool NeedGeoAssets(); } // namespace NekoGui -#define IS_NEKO_BOX (NekoGui::coreType == NekoGui::CoreType::SING_BOX) #define ROUTES_PREFIX_NAME QString("route_profiles") #define ROUTES_PREFIX QString(ROUTES_PREFIX_NAME + "/") #define RULE_SETS_DIR QString("rule_sets") diff --git a/src/main.cpp b/src/main.cpp index 20ce278..b7ed53f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -139,22 +139,6 @@ int main(int argc, char* argv[]) { QIcon::setThemeName("breeze"); } - // Load coreType - auto coreLoaded = ReadFileText("groups/coreType"); - if (coreLoaded.isEmpty()) { - NekoGui::coreType = -1; - loadTranslate(QLocale().name()); - NekoGui::coreType = NekoGui::CoreType::SING_BOX; - QDir().mkdir("groups"); - QFile file; - file.setFileName("groups/coreType"); - file.open(QIODevice::ReadWrite | QIODevice::Truncate); - file.write(Int2String(NekoGui::coreType).toUtf8()); - file.close(); - } else { - NekoGui::coreType = coreLoaded.toInt(); - } - // Dir QDir dir; bool dir_success = true; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 733949c..86fc0d6 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -141,9 +141,17 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi software_name = "Nekoray"; software_core_name = "sing-box"; // - if (QDir("dashboard").count() == 0) { - QDir().mkdir("dashboard"); - QFile::copy(":/neko/dashboard-notice.html", "dashboard/index.html"); + if (auto dashDir = QDir("dashboard"); !dashDir.exists("dashboard") && QDir().mkdir("dashboard")) { + if (auto dashFile = QFile(":/neko/dashboard-notice.html"); dashFile.exists() && dashFile.open(QIODevice::ReadOnly)) + { + auto data = dashFile.readAll(); + if (auto dest = QFile("dashboard/index.html"); dest.open(QIODevice::Truncate | QIODevice::WriteOnly)) + { + dest.write(data); + dest.close(); + } + dashFile.close(); + } } // top bar