mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 11:42:21 +08:00
chore: Adjust the chain processing execution order and default value
This commit is contained in:
parent
cff0ea425c
commit
7e8b65e61f
|
@ -428,8 +428,10 @@ impl PrfItem {
|
||||||
/// create the enhanced item by using `merge` rule
|
/// create the enhanced item by using `merge` rule
|
||||||
pub fn from_merge(uid: Option<String>) -> Result<PrfItem> {
|
pub fn from_merge(uid: Option<String>) -> Result<PrfItem> {
|
||||||
let mut id = help::get_uid("m");
|
let mut id = help::get_uid("m");
|
||||||
|
let mut template = tmpl::ITEM_MERGE.into();
|
||||||
if let Some(uid) = uid {
|
if let Some(uid) = uid {
|
||||||
id = uid;
|
id = uid;
|
||||||
|
template = tmpl::ITEM_MERGE_EMPTY.into();
|
||||||
}
|
}
|
||||||
let file = format!("{id}.yaml");
|
let file = format!("{id}.yaml");
|
||||||
|
|
||||||
|
@ -445,7 +447,7 @@ impl PrfItem {
|
||||||
option: None,
|
option: None,
|
||||||
home: None,
|
home: None,
|
||||||
updated: Some(chrono::Local::now().timestamp() as usize),
|
updated: Some(chrono::Local::now().timestamp() as usize),
|
||||||
file_data: Some(tmpl::ITEM_MERGE.into()),
|
file_data: Some(template),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,8 +138,28 @@ pub async fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
|
||||||
let mut result_map = HashMap::new(); // 保存脚本日志
|
let mut result_map = HashMap::new(); // 保存脚本日志
|
||||||
let mut exists_keys = use_keys(&config); // 保存出现过的keys
|
let mut exists_keys = use_keys(&config); // 保存出现过的keys
|
||||||
|
|
||||||
// 处理用户的profile
|
// 全局Merge和Script
|
||||||
|
if let ChainType::Merge(merge) = global_merge.data {
|
||||||
|
exists_keys.extend(use_keys(&merge));
|
||||||
|
config = use_merge(merge, config.to_owned());
|
||||||
|
}
|
||||||
|
|
||||||
|
if let ChainType::Script(script) = global_script.data {
|
||||||
|
let mut logs = vec![];
|
||||||
|
|
||||||
|
match use_script(script, config.to_owned()) {
|
||||||
|
Ok((res_config, res_logs)) => {
|
||||||
|
exists_keys.extend(use_keys(&res_config));
|
||||||
|
config = res_config;
|
||||||
|
logs.extend(res_logs);
|
||||||
|
}
|
||||||
|
Err(err) => logs.push(("exception".into(), err.to_string())),
|
||||||
|
}
|
||||||
|
|
||||||
|
result_map.insert(global_script.uid, logs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订阅关联的Merge、Script、Rules、Proxies、Groups
|
||||||
if let ChainType::Rules(rules) = rules_item.data {
|
if let ChainType::Rules(rules) = rules_item.data {
|
||||||
config = use_seq(rules, config.to_owned(), "rules");
|
config = use_seq(rules, config.to_owned(), "rules");
|
||||||
}
|
}
|
||||||
|
@ -172,27 +192,6 @@ pub async fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
|
||||||
result_map.insert(script_item.uid, logs);
|
result_map.insert(script_item.uid, logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全局Merge和Script
|
|
||||||
if let ChainType::Merge(merge) = global_merge.data {
|
|
||||||
exists_keys.extend(use_keys(&merge));
|
|
||||||
config = use_merge(merge, config.to_owned());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let ChainType::Script(script) = global_script.data {
|
|
||||||
let mut logs = vec![];
|
|
||||||
|
|
||||||
match use_script(script, config.to_owned()) {
|
|
||||||
Ok((res_config, res_logs)) => {
|
|
||||||
exists_keys.extend(use_keys(&res_config));
|
|
||||||
config = res_config;
|
|
||||||
logs.extend(res_logs);
|
|
||||||
}
|
|
||||||
Err(err) => logs.push(("exception".into(), err.to_string())),
|
|
||||||
}
|
|
||||||
|
|
||||||
result_map.insert(global_script.uid, logs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 合并默认的config
|
// 合并默认的config
|
||||||
for (key, value) in clash_config.into_iter() {
|
for (key, value) in clash_config.into_iter() {
|
||||||
if key.as_str() == Some("tun") {
|
if key.as_str() == Some("tun") {
|
||||||
|
|
|
@ -15,6 +15,13 @@ pub const ITEM_MERGE: &str = "# Profile Enhancement Merge Template for Clash Ver
|
||||||
|
|
||||||
profile:
|
profile:
|
||||||
store-selected: true
|
store-selected: true
|
||||||
|
|
||||||
|
dns:
|
||||||
|
use-system-hosts: false
|
||||||
|
";
|
||||||
|
|
||||||
|
pub const ITEM_MERGE_EMPTY: &str = "# Profile Enhancement Merge Template for Clash Verge
|
||||||
|
|
||||||
";
|
";
|
||||||
|
|
||||||
/// enhanced profile
|
/// enhanced profile
|
||||||
|
|
Loading…
Reference in New Issue
Block a user