mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-06 17:12:07 +08:00
fix(config): publish retained runtime and reconcile proxy settings
This commit is contained in:
@@ -19,6 +19,7 @@ use smartstring::alias::String;
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tauri_plugin_mihomo::Error as MihomoError;
|
||||
@@ -259,6 +260,7 @@ impl CoreManager {
|
||||
let outcome = self.perform_config_update(Some(profiles)).await?;
|
||||
if outcome.is_valid() {
|
||||
crate::config::profiles::restore_selected_nodes().await;
|
||||
handle::Handle::refresh_clash();
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!("failed to restore previous Core configuration: {outcome}"))
|
||||
@@ -324,7 +326,18 @@ impl CoreManager {
|
||||
|
||||
/// Commits the applied runtime even if restoring the system proxy subsequently fails.
|
||||
async fn validate_and_apply(&self, transaction: DraftTransaction<'_>) -> Result<ValidationOutcome> {
|
||||
let outcome = self.validate_and_apply_draft().await?;
|
||||
let runtime = Config::runtime().await;
|
||||
let original_runtime = runtime.data_arc();
|
||||
let outcome = match self.validate_and_apply_draft().await {
|
||||
Ok(outcome) => outcome,
|
||||
Err(error) => {
|
||||
transaction.rollback();
|
||||
if !Arc::ptr_eq(&original_runtime, &runtime.data_arc()) {
|
||||
handle::Handle::refresh_clash();
|
||||
}
|
||||
return Err(error);
|
||||
}
|
||||
};
|
||||
if outcome.is_valid() {
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@@ -77,12 +77,12 @@ verge_registry! {
|
||||
enable_bypass_check => NoEffect;
|
||||
enable_dns_settings => NoEffect;
|
||||
profile_dns_settings => NoEffect;
|
||||
use_default_bypass => NoEffect;
|
||||
use_default_bypass => [SystemProxy];
|
||||
system_proxy_bypass => [SystemProxy];
|
||||
proxy_guard_duration => [SystemProxy];
|
||||
proxy_auto_config => [SystemProxy];
|
||||
pac_file_content => [SystemProxy];
|
||||
proxy_host => NoEffect;
|
||||
proxy_host => [SystemProxy];
|
||||
theme_setting => NoEffect;
|
||||
web_ui_list => NoEffect;
|
||||
clash_core => NoEffect;
|
||||
@@ -173,7 +173,7 @@ mod tests {
|
||||
fn representative_verge_patches_map_to_frozen_effects() {
|
||||
assert_eq!(verge_effects(&IVerge::default()), Effects::new());
|
||||
|
||||
let cases: [(IVerge, &[Effect]); 7] = [
|
||||
let cases: [(IVerge, &[Effect]); 9] = [
|
||||
(
|
||||
verge_patch(|p| p.verge_mixed_port = Some(27899)),
|
||||
&[Effect::RestartCore],
|
||||
@@ -199,6 +199,14 @@ mod tests {
|
||||
verge_patch(|p| p.system_proxy_bypass = Some("localhost".into())),
|
||||
&[Effect::SystemProxy],
|
||||
),
|
||||
(
|
||||
verge_patch(|p| p.use_default_bypass = Some(false)),
|
||||
&[Effect::SystemProxy],
|
||||
),
|
||||
(
|
||||
verge_patch(|p| p.proxy_host = Some("localhost".into())),
|
||||
&[Effect::SystemProxy],
|
||||
),
|
||||
(
|
||||
verge_patch(|p| p.tray_event = Some("show_main_window".into())),
|
||||
&[Effect::TrayClick],
|
||||
|
||||
Reference in New Issue
Block a user