mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-18 00:11:08 +08:00
fix(seq): prepend newly added proxies to first selector group
This commit is contained in:
parent
a82bcbe86e
commit
c40cdf6b55
@ -29,6 +29,6 @@
|
|||||||
- 在 Linux NVIDIA 显卡环境下尝试禁用 WebKit DMABUF 渲染以规避潜在问题
|
- 在 Linux NVIDIA 显卡环境下尝试禁用 WebKit DMABUF 渲染以规避潜在问题
|
||||||
- Windows 下自启动改为计划任务实现
|
- Windows 下自启动改为计划任务实现
|
||||||
- 改进托盘和窗口操作频率限制实现
|
- 改进托盘和窗口操作频率限制实现
|
||||||
- 使用「编辑节点」添加节点时,自动将节点添加到第一个 `select` 类型的代理组末尾
|
- 使用「编辑节点」添加节点时,自动将节点添加到第一个 `select` 类型的代理组的第一位
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
@ -100,17 +100,24 @@ pub fn use_seq(seq: SeqMap, mut config: Mapping, field: &str) -> Mapping {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if !appended_to_selector && !added_proxy_names.is_empty() && is_selector_group(group_map) {
|
if !appended_to_selector && !added_proxy_names.is_empty() && is_selector_group(group_map) {
|
||||||
let mut seq = proxies_seq.unwrap_or_else(Sequence::new);
|
let base_seq = proxies_seq.unwrap_or_else(Sequence::new);
|
||||||
let mut existing = seq
|
let mut seq = Sequence::new();
|
||||||
.iter()
|
let mut existing = HashSet::new();
|
||||||
.filter_map(Value::as_str)
|
|
||||||
.map(str::to_owned)
|
|
||||||
.collect::<HashSet<String>>();
|
|
||||||
for name in &added_proxy_names {
|
for name in &added_proxy_names {
|
||||||
if existing.insert(name.clone()) {
|
if existing.insert(name.clone()) {
|
||||||
seq.push(Value::String(name.clone()));
|
seq.push(Value::String(name.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for value in base_seq {
|
||||||
|
match &value {
|
||||||
|
Value::String(name) => {
|
||||||
|
if existing.insert(name.to_owned()) {
|
||||||
|
seq.push(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => seq.push(value),
|
||||||
|
}
|
||||||
|
}
|
||||||
proxies_seq = Some(seq);
|
proxies_seq = Some(seq);
|
||||||
appended_to_selector = true;
|
appended_to_selector = true;
|
||||||
}
|
}
|
||||||
@ -270,7 +277,7 @@ proxy-groups:
|
|||||||
.as_sequence()
|
.as_sequence()
|
||||||
.expect("group proxies should be a sequence");
|
.expect("group proxies should be a sequence");
|
||||||
let names: Vec<&str> = group1_proxies.iter().filter_map(Value::as_str).collect();
|
let names: Vec<&str> = group1_proxies.iter().filter_map(Value::as_str).collect();
|
||||||
assert_eq!(names, vec!["proxy1", "proxy3", "proxy4"]);
|
assert_eq!(names, vec!["proxy3", "proxy4", "proxy1"]);
|
||||||
|
|
||||||
let group2_proxies = groups[1]
|
let group2_proxies = groups[1]
|
||||||
.as_mapping()
|
.as_mapping()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user