mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-20 19:12:09 +08:00
Merge branch 'dev' into dev
This commit is contained in:
@@ -264,14 +264,14 @@ pub fn create_backup() -> Result<(String, PathBuf), Error> {
|
||||
zip.write_all(fs::read(dirs::clash_path()?)?.as_slice())?;
|
||||
|
||||
let mut verge_config: serde_json::Value =
|
||||
serde_yaml::from_str(&fs::read_to_string(dirs::verge_path()?)?)?;
|
||||
serde_yaml_ng::from_str(&fs::read_to_string(dirs::verge_path()?)?)?;
|
||||
if let Some(obj) = verge_config.as_object_mut() {
|
||||
obj.remove("webdav_username");
|
||||
obj.remove("webdav_password");
|
||||
obj.remove("webdav_url");
|
||||
}
|
||||
zip.start_file(dirs::VERGE_CONFIG, options)?;
|
||||
zip.write_all(serde_yaml::to_string(&verge_config)?.as_bytes())?;
|
||||
zip.write_all(serde_yaml_ng::to_string(&verge_config)?.as_bytes())?;
|
||||
|
||||
zip.start_file(dirs::PROFILE_YAML, options)?;
|
||||
zip.write_all(fs::read(dirs::profiles_path()?)?.as_slice())?;
|
||||
|
||||
@@ -317,7 +317,7 @@ impl CoreManager {
|
||||
};
|
||||
// 对YAML文件尝试解析,只检查语法正确性
|
||||
logging!(info, Type::Config, true, "进行YAML语法检查");
|
||||
match serde_yaml::from_str::<serde_yaml::Value>(&content) {
|
||||
match serde_yaml_ng::from_str::<serde_yaml_ng::Value>(&content) {
|
||||
Ok(_) => {
|
||||
logging!(info, Type::Config, true, "YAML语法检查通过");
|
||||
Ok((true, String::new()))
|
||||
|
||||
@@ -60,8 +60,6 @@ impl Timer {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
logging!(info, Type::Timer, true, "Initializing timer...");
|
||||
|
||||
// Initialize timer tasks
|
||||
if let Err(e) = self.refresh().await {
|
||||
// Reset initialization flag on error
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
logging,
|
||||
module::lightweight::is_in_lightweight_mode,
|
||||
singleton_lazy,
|
||||
utils::{dirs::find_target_icons, i18n::t, resolve::VERSION},
|
||||
utils::{dirs::find_target_icons, i18n::t},
|
||||
Type,
|
||||
};
|
||||
|
||||
@@ -189,7 +189,11 @@ impl Default for Tray {
|
||||
singleton_lazy!(Tray, TRAY, Tray::default);
|
||||
|
||||
impl Tray {
|
||||
pub fn init(&self) -> Result<()> {
|
||||
pub async fn init(&self) -> Result<()> {
|
||||
let app_handle = handle::Handle::global()
|
||||
.app_handle()
|
||||
.ok_or_else(|| anyhow::anyhow!("Failed to get app handle for tray initialization"))?;
|
||||
self.create_tray_from_handle(&app_handle).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -409,14 +413,6 @@ impl Tray {
|
||||
}
|
||||
};
|
||||
|
||||
let version = match VERSION.get() {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
log::warn!(target: "app", "更新托盘提示失败: 版本信息不存在");
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
let verge = Config::verge().await.latest_ref().clone();
|
||||
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
|
||||
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);
|
||||
@@ -447,6 +443,7 @@ impl Tray {
|
||||
let tun_text = t("TUN").await;
|
||||
let profile_text = t("Profile").await;
|
||||
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
if let Some(tray) = app_handle.tray_by_id("main") {
|
||||
let _ = tray.set_tooltip(Some(&format!(
|
||||
"Clash Verge {version}\n{}: {}\n{}: {}\n{}: {}",
|
||||
@@ -473,10 +470,6 @@ impl Tray {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 取消订阅 traffic 数据
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn unsubscribe_traffic(&self) {}
|
||||
|
||||
pub async fn create_tray_from_handle(&self, app_handle: &AppHandle) -> Result<()> {
|
||||
log::info!(target: "app", "正在从AppHandle创建系统托盘");
|
||||
|
||||
@@ -599,6 +592,7 @@ async fn create_tray_menu(
|
||||
let unknown_version = String::from("unknown");
|
||||
let version = VERSION.get().unwrap_or(&unknown_version);
|
||||
|
||||
|
||||
let hotkeys = Config::verge()
|
||||
.await
|
||||
.latest_ref()
|
||||
|
||||
Reference in New Issue
Block a user