mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-14 23:02:14 +08:00
refactor(tray): deduplicate icon getters, update_icon, and menu+icon combo
- Consolidate 3 near-identical icon getter functions into load_icon/default_icon with IconKind enum - Merge two platform-gated update_icon implementations into one - Extract update_menu_and_icon to eliminate duplicate combo in feat/config.rs and feat/clash.rs
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::{
|
||||
process::AsyncHandler,
|
||||
utils::{self, resolve::reset_resolve_done},
|
||||
};
|
||||
use clash_verge_logging::{Type, logging, logging_error};
|
||||
use clash_verge_logging::{Type, logging};
|
||||
use serde_yaml_ng::{Mapping, Value};
|
||||
use smartstring::alias::String;
|
||||
|
||||
@@ -86,13 +86,7 @@ pub async fn change_clash_mode(mode: String) {
|
||||
let clash_data = clash.data_arc();
|
||||
if clash_data.save_config().await.is_ok() {
|
||||
handle::Handle::refresh_clash();
|
||||
logging_error!(Type::Tray, tray::Tray::global().update_menu().await);
|
||||
logging_error!(
|
||||
Type::Tray,
|
||||
tray::Tray::global()
|
||||
.update_icon(&Config::verge().await.data_arc())
|
||||
.await
|
||||
);
|
||||
tray::Tray::global().update_menu_and_icon().await;
|
||||
}
|
||||
|
||||
let is_auto_close_connection = Config::verge().await.data_arc().auto_close_connection.unwrap_or(false);
|
||||
|
||||
@@ -20,13 +20,7 @@ pub async fn patch_clash(patch: &Mapping) -> Result<()> {
|
||||
CoreManager::global().restart_core().await?;
|
||||
} else {
|
||||
if patch.get("mode").is_some() {
|
||||
logging_error!(Type::Tray, tray::Tray::global().update_menu().await);
|
||||
logging_error!(
|
||||
Type::Tray,
|
||||
tray::Tray::global()
|
||||
.update_icon(&Config::verge().await.data_arc())
|
||||
.await
|
||||
);
|
||||
tray::Tray::global().update_menu_and_icon().await;
|
||||
}
|
||||
Config::runtime().await.edit_draft(|d| d.patch_config(patch));
|
||||
CoreManager::global().update_config().await?;
|
||||
|
||||
Reference in New Issue
Block a user