optimize ui

This commit is contained in:
arm64v8a
2023-04-10 13:57:36 +09:00
parent 2f22371777
commit 5d346addec
12 changed files with 98 additions and 11 deletions

View File

@@ -856,6 +856,20 @@ namespace NekoRay {
routeObj.remove("auto_detect_interface"); routeObj.remove("auto_detect_interface");
} }
status->result->coreConfig.insert("route", routeObj); status->result->coreConfig.insert("route", routeObj);
// experimental
QJsonObject experimentalObj;
if (NekoRay::dataStore->core_box_clash_api > 0) {
QJsonObject clash_api = {
{"external_controller", "127.0.0.1:" + Int2String(NekoRay::dataStore->core_box_clash_api)},
{"secret", NekoRay::dataStore->core_box_clash_api_secret},
{"external_ui", "dashboard"},
};
experimentalObj["clash_api"] = clash_api;
}
if (!experimentalObj.isEmpty()) status->result->coreConfig.insert("experimental", experimentalObj);
} }
QString WriteVPNSingBoxConfig() { QString WriteVPNSingBoxConfig() {

View File

@@ -76,6 +76,8 @@ namespace NekoRay {
_add(new configItem("splitter_state", &splitter_state, itemType::string)); _add(new configItem("splitter_state", &splitter_state, itemType::string));
_add(new configItem("utlsFingerprint", &utlsFingerprint, itemType::string)); _add(new configItem("utlsFingerprint", &utlsFingerprint, itemType::string));
_add(new configItem("core_box_auto_detect_interface", &core_box_auto_detect_interface, itemType::boolean)); _add(new configItem("core_box_auto_detect_interface", &core_box_auto_detect_interface, itemType::boolean));
_add(new configItem("core_box_clash_api", &core_box_clash_api, itemType::integer));
_add(new configItem("core_box_clash_api_secret", &core_box_clash_api_secret, itemType::string));
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
_add(new configItem("vpn_already_admin", &vpn_already_admin, itemType::boolean)); _add(new configItem("vpn_already_admin", &vpn_already_admin, itemType::boolean));
#endif #endif

View File

@@ -151,6 +151,8 @@ namespace NekoRay {
// Core // Core
bool core_box_auto_detect_interface = true; bool core_box_auto_detect_interface = true;
int core_box_clash_api = -9090;
QString core_box_clash_api_secret = "";
// Other Core // Other Core
ExtraCore *extraCore = new ExtraCore; ExtraCore *extraCore = new ExtraCore;

13
res/dashboard-notice.html Normal file
View File

@@ -0,0 +1,13 @@
<html>
<head></head>
<body>
<h3>
<p>Please put your clash dashboard files to "nekoray/config/dashboard" dir.</p>
<p>For example, you can download from the following URL.</p>
<a href="https://github.com/MetaCubeX/Yacd-meta/archive/refs/heads/gh-pages.zip">Yacd-meta</a>
</h3>
</body>
</html>

View File

@@ -20,5 +20,6 @@
<file>neko.css</file> <file>neko.css</file>
<file>vpn/vpn-run-root.sh</file> <file>vpn/vpn-run-root.sh</file>
<file>vpn/sing-box-vpn.json</file> <file>vpn/sing-box-vpn.json</file>
<file>dashboard-notice.html</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -406,6 +406,8 @@ namespace NekoRay::sub {
content = resp.data; content = resp.data;
sub_user_info = NetworkRequestHelper::GetHeader(resp.header, "Subscription-UserInfo"); sub_user_info = NetworkRequestHelper::GetHeader(resp.header, "Subscription-UserInfo");
MW_show_log("<<<<<<<< " + QObject::tr("Subscription request fininshed: %1").arg(groupName));
} }
QList<QSharedPointer<ProxyEntity>> in; // 更新前 QList<QSharedPointer<ProxyEntity>> in; // 更新前
@@ -461,11 +463,11 @@ namespace NekoRay::sub {
QString notice_added; QString notice_added;
for (const auto &ent: only_out) { for (const auto &ent: only_out) {
notice_added += ent->bean->DisplayTypeAndName() + "\n"; notice_added += "[+] " + ent->bean->DisplayTypeAndName() + "\n";
} }
QString notice_deleted; QString notice_deleted;
for (const auto &ent: only_in) { for (const auto &ent: only_in) {
notice_deleted += ent->bean->DisplayTypeAndName() + "\n"; notice_deleted += "[-] " + ent->bean->DisplayTypeAndName() + "\n";
} }
auto change = "\n" + QObject::tr("Added %1 profiles:\n%2\nDeleted %3 Profiles:\n%4") auto change = "\n" + QObject::tr("Added %1 profiles:\n%2\nDeleted %3 Profiles:\n%4")

View File

@@ -1471,6 +1471,10 @@ Direct: %2</source>
<source>Enable System Proxy</source> <source>Enable System Proxy</source>
<translation type="obsolete">پروکسی سیستم را فعال کنید</translation> <translation type="obsolete">پروکسی سیستم را فعال کنید</translation>
</message> </message>
<message>
<source>Subscription request fininshed: %1</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name> <name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name>

View File

@@ -1461,12 +1461,8 @@ As of January 1, 2022, compatibility with MD5 authentication information will be
<translation>...</translation> <translation>...</translation>
</message> </message>
<message> <message>
<source>Enable VPN</source> <source>Subscription request fininshed: %1</source>
<translation type="obsolete"> VPN</translation> <translation>: %1</translation>
</message>
<message>
<source>Enable System Proxy</source>
<translation type="obsolete"></translation>
</message> </message>
</context> </context>
<context> <context>

View File

@@ -378,7 +378,7 @@ void DialogBasicSettings::on_inbound_auth_clicked() {
connect(box, &QDialogButtonBox::accepted, w, [=] { connect(box, &QDialogButtonBox::accepted, w, [=] {
NekoRay::dataStore->inbound_auth->username = user->text(); NekoRay::dataStore->inbound_auth->username = user->text();
NekoRay::dataStore->inbound_auth->password = pass->text(); NekoRay::dataStore->inbound_auth->password = pass->text();
NekoRay::dataStore->Save(); MW_dialog_message(Dialog_DialogBasicSettings, "UpdateDataStore");
w->accept(); w->accept();
}); });
connect(box, &QDialogButtonBox::rejected, w, &QDialog::reject); connect(box, &QDialogButtonBox::rejected, w, &QDialog::reject);
@@ -397,12 +397,33 @@ void DialogBasicSettings::on_core_settings_clicked() {
// //
auto line = -1; auto line = -1;
QCheckBox *core_box_auto_detect_interface; QCheckBox *core_box_auto_detect_interface;
QCheckBox *core_box_enable_clash_api;
QLineEdit *core_box_clash_api;
QLineEdit *core_box_clash_api_secret;
if (IS_NEKO_BOX) { if (IS_NEKO_BOX) {
auto core_box_auto_detect_interface_l = new QLabel("auto_detect_interface"); auto core_box_auto_detect_interface_l = new QLabel("auto_detect_interface");
core_box_auto_detect_interface = new QCheckBox; core_box_auto_detect_interface = new QCheckBox;
core_box_auto_detect_interface->setChecked(NekoRay::dataStore->core_box_auto_detect_interface); core_box_auto_detect_interface->setChecked(NekoRay::dataStore->core_box_auto_detect_interface);
layout->addWidget(core_box_auto_detect_interface_l, ++line, 0); layout->addWidget(core_box_auto_detect_interface_l, ++line, 0);
layout->addWidget(core_box_auto_detect_interface, line, 1); layout->addWidget(core_box_auto_detect_interface, line, 1);
//
auto core_box_enable_clash_api_l = new QLabel("Enable Clash API");
core_box_enable_clash_api = new QCheckBox;
core_box_enable_clash_api->setChecked(NekoRay::dataStore->core_box_clash_api > 0);
layout->addWidget(core_box_enable_clash_api_l, ++line, 0);
layout->addWidget(core_box_enable_clash_api, line, 1);
//
auto core_box_clash_api_l = new QLabel("Clash API Listen Port");
core_box_clash_api = new MyLineEdit;
core_box_clash_api->setText(Int2String(std::abs(NekoRay::dataStore->core_box_clash_api)));
layout->addWidget(core_box_clash_api_l, ++line, 0);
layout->addWidget(core_box_clash_api, line, 1);
//
auto core_box_clash_api_secret_l = new QLabel("Clash API Secret");
core_box_clash_api_secret = new MyLineEdit;
core_box_clash_api_secret->setText(NekoRay::dataStore->core_box_clash_api_secret);
layout->addWidget(core_box_clash_api_secret_l, ++line, 0);
layout->addWidget(core_box_clash_api_secret, line, 1);
} }
// //
auto box = new QDialogButtonBox; auto box = new QDialogButtonBox;
@@ -411,8 +432,10 @@ void DialogBasicSettings::on_core_settings_clicked() {
connect(box, &QDialogButtonBox::accepted, w, [=] { connect(box, &QDialogButtonBox::accepted, w, [=] {
if (IS_NEKO_BOX) { if (IS_NEKO_BOX) {
NekoRay::dataStore->core_box_auto_detect_interface = core_box_auto_detect_interface->isChecked(); NekoRay::dataStore->core_box_auto_detect_interface = core_box_auto_detect_interface->isChecked();
NekoRay::dataStore->core_box_clash_api = core_box_clash_api->text().toInt() * (core_box_enable_clash_api->isChecked() ? 1 : -1);
NekoRay::dataStore->core_box_clash_api_secret = core_box_clash_api_secret->text();
} }
NekoRay::dataStore->Save(); MW_dialog_message(Dialog_DialogBasicSettings, "UpdateDataStore");
w->accept(); w->accept();
}); });
connect(box, &QDialogButtonBox::rejected, w, &QDialog::reject); connect(box, &QDialogButtonBox::rejected, w, &QDialog::reject);

View File

@@ -288,7 +288,7 @@
<item> <item>
<widget class="QLineEdit" name="max_log_line"> <widget class="QLineEdit" name="max_log_line">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>

View File

@@ -31,13 +31,38 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="core"> <widget class="QComboBox" name="core">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="as_json"> <widget class="QPushButton" name="as_json">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Json Editor</string> <string>Json Editor</string>
</property> </property>

View File

@@ -100,6 +100,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
if (!Preset::SingBox::DomainStrategy.contains(NekoRay::dataStore->outbound_domain_strategy)) { if (!Preset::SingBox::DomainStrategy.contains(NekoRay::dataStore->outbound_domain_strategy)) {
NekoRay::dataStore->outbound_domain_strategy = ""; NekoRay::dataStore->outbound_domain_strategy = "";
} }
//
if (QDir("dashboard").isEmpty()) {
QDir().mkdir("dashboard");
QFile::copy(":/neko/dashboard-notice.html", "dashboard/index.html");
}
} }
// top bar // top bar