mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-22 19:52:14 +08:00
* refactor(ipc): generate bindings with Specta * fix(profile): project IPC inputs to consumed fields * fix(events): remove unused refresh payloads * fix(webdav): return only consumed backup metadata * fix(network): trim unused interface metadata * fix(sysinfo): return only displayed system fields * chore(knip): check generated runtime exports * fix(proxy): confirm runtime chain updates before UI changes * fix(clipboard): propagate proxy environment copy failures * refactor(dns): remove ignored runtime patch * refactor(core): trim unused upgrade response fields * refactor(ipc): avoid redundant response copies * refactor(proxy): clarify automatic proxy query naming * chore(tests): remove added IPC regression tests * refactor(ipc): enforce typed command boundaries * chore(contract): check generated bindings before push * refactor(ipc): remove unused proxy liveness payloads
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
use super::{CmdResult, proxy_aware_error};
|
|
use crate::{
|
|
cmd::StringifyErr as _,
|
|
config::IVerge,
|
|
core::notification::{self, FailedOperation},
|
|
feat,
|
|
};
|
|
use clash_verge_draft::SharedDraft;
|
|
|
|
/// 获取Verge配置
|
|
#[tauri::command]
|
|
#[specta::specta]
|
|
pub async fn get_verge_config() -> CmdResult<SharedDraft<IVerge>> {
|
|
feat::fetch_verge_config().await.stringify_err()
|
|
}
|
|
|
|
/// 修改Verge配置
|
|
#[tauri::command]
|
|
#[specta::specta]
|
|
pub async fn patch_verge_config(payload: IVerge) -> CmdResult {
|
|
let operation = system_proxy_operation(&payload);
|
|
let result = match operation {
|
|
Some(operation) => notification::asking_for(operation, Box::pin(feat::patch_verge(&payload, false))).await,
|
|
None => feat::patch_verge(&payload, false).await,
|
|
};
|
|
result.map_err(|error| proxy_aware_error(&error).asking_for(operation))
|
|
}
|
|
|
|
/// Extract a system proxy operation from a Verge patch.
|
|
const fn system_proxy_operation(payload: &IVerge) -> Option<FailedOperation> {
|
|
match payload.enable_system_proxy {
|
|
Some(true) => Some(FailedOperation::SystemProxyEnable),
|
|
Some(false) => Some(FailedOperation::SystemProxyDisable),
|
|
None => None,
|
|
}
|
|
}
|