mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
refactor: simplify function return types and remove unnecessary wraps
This commit is contained in:
@@ -27,7 +27,10 @@ impl CoreManager {
|
||||
|
||||
match *self.get_running_mode() {
|
||||
RunningMode::Service => self.stop_core_by_service().await,
|
||||
RunningMode::Sidecar => self.stop_core_by_sidecar(),
|
||||
RunningMode::Sidecar => {
|
||||
self.stop_core_by_sidecar();
|
||||
Ok(())
|
||||
}
|
||||
RunningMode::NotRunning => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ impl CoreManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn stop_core_by_sidecar(&self) -> Result<()> {
|
||||
pub(super) fn stop_core_by_sidecar(&self) {
|
||||
logging!(info, Type::Core, "Stopping sidecar");
|
||||
defer! {
|
||||
self.set_running_mode(RunningMode::NotRunning);
|
||||
@@ -106,7 +106,6 @@ impl CoreManager {
|
||||
drop(child);
|
||||
logging!(trace, Type::Core, "Sidecar stopped (PID: {:?})", pid);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) async fn start_core_by_service(&self) -> Result<()> {
|
||||
|
||||
@@ -456,12 +456,12 @@ impl ServiceManager {
|
||||
Self(ServiceStatus::Unavailable("Need Checks".into()))
|
||||
}
|
||||
|
||||
pub const fn config() -> Option<clash_verge_service_ipc::IpcConfig> {
|
||||
Some(clash_verge_service_ipc::IpcConfig {
|
||||
pub const fn config() -> clash_verge_service_ipc::IpcConfig {
|
||||
clash_verge_service_ipc::IpcConfig {
|
||||
default_timeout: Duration::from_millis(30),
|
||||
retry_delay: Duration::from_millis(250),
|
||||
max_retries: 6,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn init(&mut self) -> Result<()> {
|
||||
|
||||
@@ -100,13 +100,12 @@ impl Sysopt {
|
||||
self.initialed.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
pub fn init_guard_sysproxy(&self) -> Result<()> {
|
||||
pub fn init_guard_sysproxy(&self) {
|
||||
// 使用事件驱动代理管理器
|
||||
let proxy_manager = EventDrivenProxyManager::global();
|
||||
proxy_manager.notify_app_started();
|
||||
|
||||
logging!(info, Type::Core, "已启用事件驱动代理守卫");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// init the sysproxy
|
||||
|
||||
@@ -301,8 +301,8 @@ impl Tray {
|
||||
let verge = Config::verge().await.latest_arc();
|
||||
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
||||
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
||||
let tun_mode_available = cmd::system::is_admin().unwrap_or_default()
|
||||
|| service::is_service_available().await.is_ok();
|
||||
let tun_mode_available =
|
||||
cmd::system::is_admin() || service::is_service_available().await.is_ok();
|
||||
let mode = {
|
||||
Config::clash()
|
||||
.await
|
||||
@@ -640,7 +640,7 @@ fn create_subcreate_proxy_menu_item(
|
||||
current_profile_selected: &[PrfSelected],
|
||||
proxy_group_order_map: Option<HashMap<String, usize>>,
|
||||
proxy_nodes_data: Result<Proxies>,
|
||||
) -> Result<Vec<Submenu<Wry>>> {
|
||||
) -> Vec<Submenu<Wry>> {
|
||||
let proxy_submenus: Vec<Submenu<Wry>> = {
|
||||
let mut submenus: Vec<(String, usize, Submenu<Wry>)> = Vec::new();
|
||||
|
||||
@@ -767,7 +767,7 @@ fn create_subcreate_proxy_menu_item(
|
||||
.map(|(_, _, submenu)| submenu)
|
||||
.collect()
|
||||
};
|
||||
Ok(proxy_submenus)
|
||||
proxy_submenus
|
||||
}
|
||||
|
||||
fn create_proxy_menu_item(
|
||||
@@ -955,7 +955,7 @@ async fn create_tray_menu(
|
||||
¤t_profile_selected,
|
||||
proxy_group_order_map,
|
||||
proxy_nodes_data.map_err(anyhow::Error::from),
|
||||
)?;
|
||||
);
|
||||
|
||||
let (proxies_menu, inline_proxy_items) = create_proxy_menu_item(
|
||||
app_handle,
|
||||
|
||||
Reference in New Issue
Block a user