feat: Clear servers before updating subscription

This commit is contained in:
arm64v8a
2022-10-30 13:15:08 +09:00
parent 91f016bdb2
commit 474e33a32a
6 changed files with 34 additions and 5 deletions

View File

@@ -59,6 +59,7 @@ namespace NekoRay {
_add(new configItem("vpn_bypass_cidr", &vpn_bypass_cidr, itemType::string)); _add(new configItem("vpn_bypass_cidr", &vpn_bypass_cidr, itemType::string));
_add(new configItem("check_include_pre", &check_include_pre, itemType::boolean)); _add(new configItem("check_include_pre", &check_include_pre, itemType::boolean));
_add(new configItem("sp_format", &system_proxy_format, itemType::string)); _add(new configItem("sp_format", &system_proxy_format, itemType::string));
_add(new configItem("sub_clear", &sub_clear, itemType::boolean));
} }
void DataStore::UpdateStartedId(int id) { void DataStore::UpdateStartedId(int id) {

View File

@@ -59,8 +59,6 @@ namespace NekoRay {
// Misc // Misc
QString log_level = "warning"; QString log_level = "warning";
QString user_agent = "Nekoray/1.0 (Prefer Clash Format)";
bool sub_use_proxy = false;
QString test_url = "http://cp.cloudflare.com/"; QString test_url = "http://cp.cloudflare.com/";
int test_concurrent = 5; int test_concurrent = 5;
int traffic_loop_interval = 500; int traffic_loop_interval = 500;
@@ -74,6 +72,11 @@ namespace NekoRay {
bool check_include_pre = false; bool check_include_pre = false;
QString system_proxy_format = ""; QString system_proxy_format = "";
// Subscription
QString user_agent = "Nekoray/1.0 (Prefer Clash Format)";
bool sub_use_proxy = false;
bool sub_clear = false;
// Security // Security
bool insecure_hint = true; bool insecure_hint = true;
bool skip_cert = false; bool skip_cert = false;

View File

@@ -357,6 +357,14 @@ namespace NekoRay::sub {
group->info = sub_user_info; group->info = sub_user_info;
group->order.clear(); group->order.clear();
group->Save(); group->Save();
//
if (dataStore->sub_clear) {
showLog(QObject::tr("Clearing servers..."));
for (const auto &profile: in) {
profileManager->DeleteProfile(profile->id);
}
in = {};
}
} }
// 解析并添加 profile // 解析并添加 profile

View File

@@ -199,6 +199,10 @@
<source>Advanced system proxy settings. Please select a format.</source> <source>Advanced system proxy settings. Please select a format.</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Clear servers before updating subscription</source>
<translation></translation>
</message>
</context> </context>
<context> <context>
<name>DialogEditGroup</name> <name>DialogEditGroup</name>
@@ -1360,6 +1364,10 @@ As of January 1, 2022, compatibility with MD5 authentication information will be
<source>Select</source> <source>Select</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Clearing servers...</source>
<translation>...</translation>
</message>
</context> </context>
<context> <context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name> <name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name>

View File

@@ -145,6 +145,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
ui->user_agent->setText(NekoRay::dataStore->user_agent); ui->user_agent->setText(NekoRay::dataStore->user_agent);
D_LOAD_BOOL(sub_use_proxy) D_LOAD_BOOL(sub_use_proxy)
D_LOAD_BOOL(sub_clear)
// Core // Core
@@ -268,6 +269,7 @@ void DialogBasicSettings::accept() {
NekoRay::dataStore->user_agent = ui->user_agent->text(); NekoRay::dataStore->user_agent = ui->user_agent->text();
D_SAVE_BOOL(sub_use_proxy) D_SAVE_BOOL(sub_use_proxy)
D_SAVE_BOOL(sub_clear)
// Core // Core

View File

@@ -421,6 +421,13 @@
<string>Subscription</string> <string>Subscription</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
<widget class="QCheckBox" name="sub_use_proxy">
<property name="text">
<string>Use proxy when updating subscription</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="MyLineEdit" name="user_agent"/> <widget class="MyLineEdit" name="user_agent"/>
</item> </item>
@@ -431,10 +438,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<widget class="QCheckBox" name="sub_use_proxy"> <widget class="QCheckBox" name="sub_clear">
<property name="text"> <property name="text">
<string>Use proxy when updating subscription</string> <string>Clear servers before updating subscription</string>
</property> </property>
</widget> </widget>
</item> </item>