更新ui
This commit is contained in:
+2
-25
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -1,8 +1,11 @@
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <initializer_list>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
#include "base/export.h"
|
||||
@@ -21,6 +24,68 @@ std::string yaml_to_string(const YAML::Node& node) {
|
||||
void write_yaml_file(const std::string& path, const YAML::Node& node) {
|
||||
write_file_content(path, yaml_to_string(node));
|
||||
}
|
||||
int first_number_or_max(std::string_view text, size_t start) {
|
||||
int result = 0;
|
||||
bool has_number = false;
|
||||
for (size_t i = start; i < text.size(); ++i) {
|
||||
const auto ch = static_cast<unsigned char>(text[i]);
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
result = result * 10 + ch - '0';
|
||||
has_number = true;
|
||||
}
|
||||
else if (has_number) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return has_number ? result : std::numeric_limits<int>::max();
|
||||
}
|
||||
int download_rate_sort_value(std::string_view name) {
|
||||
if (name.find("0.01倍") != std::string_view::npos) {
|
||||
return 1;
|
||||
}
|
||||
if (name.find("0.1倍") != std::string_view::npos) {
|
||||
return 10;
|
||||
}
|
||||
return std::numeric_limits<int>::max();
|
||||
}
|
||||
int download_country_sort_value(std::string_view name) {
|
||||
if (name.find("美国") != std::string_view::npos) {
|
||||
return 0;
|
||||
}
|
||||
if (name.find("日本") != std::string_view::npos) {
|
||||
return 1;
|
||||
}
|
||||
if (name.find("新加坡") != std::string_view::npos) {
|
||||
return 2;
|
||||
}
|
||||
return std::numeric_limits<int>::max();
|
||||
}
|
||||
int download_risk_sort_value(std::string_view name) {
|
||||
constexpr std::string_view key = "风控";
|
||||
const auto pos = name.find(key);
|
||||
return pos == std::string_view::npos ? std::numeric_limits<int>::max() : first_number_or_max(name, pos + key.size());
|
||||
}
|
||||
std::vector<std::string> sort_download_proxy_list(std::vector<std::string> list) {
|
||||
std::stable_sort(list.begin(), list.end(), [](const std::string& left, const std::string& right) {
|
||||
const auto left_rate = download_rate_sort_value(left);
|
||||
const auto right_rate = download_rate_sort_value(right);
|
||||
if (left_rate != right_rate) {
|
||||
return left_rate < right_rate;
|
||||
}
|
||||
const auto left_country = download_country_sort_value(left);
|
||||
const auto right_country = download_country_sort_value(right);
|
||||
if (left_country != right_country) {
|
||||
return left_country < right_country;
|
||||
}
|
||||
const auto left_risk = download_risk_sort_value(left);
|
||||
const auto right_risk = download_risk_sort_value(right);
|
||||
if (left_risk != right_risk) {
|
||||
return left_risk < right_risk;
|
||||
}
|
||||
return left < right;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
#define Key_Word(kw) bool kw = contain(name, #kw); \
|
||||
if (kw) map.push(#kw, name);
|
||||
void out_config_yml() {
|
||||
@@ -63,7 +128,7 @@ void out_config_yml() {
|
||||
|
||||
|
||||
auto download = "📥下载";
|
||||
auto download_yaml = make_select_group(download, props.get_from_groups({"🔥美国0.01倍", "🔥美国0.1倍", "🔥日本0.1倍", "🔥新加坡0.1倍"}));
|
||||
auto download_yaml = make_select_group(download, sort_download_proxy_list(props.get_from_groups({"🔥美国0.01倍", "🔥美国0.1倍", "🔥日本0.1倍", "🔥新加坡0.1倍"})));
|
||||
groups_node.push_back(download_yaml);
|
||||
for (const auto& name : name_set) {
|
||||
if (name == "DIRECT") continue;
|
||||
|
||||
@@ -12,7 +12,7 @@ if ( [string]::IsNullOrWhiteSpace($scriptDir))
|
||||
|
||||
$configDir = Join-Path $scriptDir "config"
|
||||
$configFile = Join-Path $configDir "config.yaml"
|
||||
$exe = Join-Path $configDir "mihomo-windows-amd64-v3-go125.exe"
|
||||
$exe = Join-Path $configDir "mihomo.exe"
|
||||
|
||||
Set-Location -LiteralPath $configDir
|
||||
|
||||
|
||||
+23
-23
@@ -1,29 +1,29 @@
|
||||
rule-providers:
|
||||
lan_direct:
|
||||
type: inline
|
||||
behavior: classical
|
||||
payload:
|
||||
- IP-CIDR,1.2.3.4/32,no-resolve
|
||||
- IP-CIDR,10.0.0.0/8,no-resolve
|
||||
- IP-CIDR,172.16.0.0/12,no-resolve
|
||||
- IP-CIDR,192.168.0.0/16,no-resolve
|
||||
- IP-CIDR,127.0.0.0/8,no-resolve
|
||||
- IP-CIDR,169.254.0.0/16,no-resolve
|
||||
- IP-CIDR6,::1/128,no-resolve
|
||||
- IP-CIDR6,fc00::/7,no-resolve
|
||||
- IP-CIDR6,fe80::/10,no-resolve
|
||||
# lan_direct:
|
||||
# type: inline
|
||||
# behavior: classical
|
||||
# payload:
|
||||
# - IP-CIDR,1.2.3.4/32,no-resolve
|
||||
# - IP-CIDR,10.0.0.0/8,no-resolve
|
||||
# - IP-CIDR,172.16.0.0/12,no-resolve
|
||||
# - IP-CIDR,192.168.0.0/16,no-resolve
|
||||
# - IP-CIDR,127.0.0.0/8,no-resolve
|
||||
# - IP-CIDR,169.254.0.0/16,no-resolve
|
||||
# - IP-CIDR6,::1/128,no-resolve
|
||||
# - IP-CIDR6,fc00::/7,no-resolve
|
||||
# - IP-CIDR6,fe80::/10,no-resolve
|
||||
|
||||
sub-rules:
|
||||
clion_rule_default_reject:
|
||||
- RULE-SET,lan_direct,DIRECT
|
||||
- DOMAIN-KEYWORD,jetbrains,REJECT
|
||||
- MATCH,REJECT
|
||||
clion_rule_default_direct:
|
||||
- RULE-SET,lan_direct,DIRECT
|
||||
- DOMAIN-KEYWORD,jetbrains,REJECT
|
||||
- MATCH,DIRECT
|
||||
# clion_rule_default_reject:
|
||||
# - RULE-SET,lan_direct,DIRECT
|
||||
# - DOMAIN-KEYWORD,jetbrains,REJECT
|
||||
# - MATCH,REJECT
|
||||
# clion_rule_default_direct:
|
||||
# - RULE-SET,lan_direct,DIRECT
|
||||
# - DOMAIN-KEYWORD,jetbrains,REJECT
|
||||
# - MATCH,DIRECT
|
||||
|
||||
|
||||
rules:
|
||||
- SUB-RULE,(PROCESS-NAME,clion64.exe),clion_rule_default_reject
|
||||
- SUB-RULE,(PROCESS-NAME,clion64.exe),clion_rule_default_direct
|
||||
# - SUB-RULE,(PROCESS-NAME,clion64.exe),clion_rule_default_reject
|
||||
# - SUB-RULE,(PROCESS-NAME,clion64.exe),clion_rule_default_direct
|
||||
Reference in New Issue
Block a user