From 07b424cb09a128522dcfa914588f07e2a248d91c Mon Sep 17 00:00:00 2001 From: Tunglies Date: Mon, 21 Apr 2025 00:06:37 +0800 Subject: [PATCH] fix: cargo clippy errors --- src-tauri/src/core/sysopt.rs | 6 ++++-- src-tauri/src/lib.rs | 1 - src-tauri/src/utils/autostart.rs | 34 +++++++++++++++++--------------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src-tauri/src/core/sysopt.rs b/src-tauri/src/core/sysopt.rs index 91b2c4c5..fc565600 100644 --- a/src-tauri/src/core/sysopt.rs +++ b/src-tauri/src/core/sysopt.rs @@ -1,9 +1,11 @@ +#[cfg(target_os = "windows")] +use crate::utils::autostart as startup_shortcut; use crate::{ config::{Config, IVerge}, core::handle::Handle, logging, logging_error, process::AsyncHandler, - utils::{autostart as startup_shortcut, logging::Type}, + utils::logging::Type, }; use anyhow::Result; use once_cell::sync::OnceCell; @@ -363,7 +365,7 @@ impl Sysopt { } else { let sysproxy = Sysproxy { enable: true, - host: proxy_host.into(), + host: proxy_host, port, bypass: get_bypass(), }; diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 40afeb34..01a22da7 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -19,7 +19,6 @@ use tauri::AppHandle; use tauri::Manager; use tauri_plugin_autostart::MacosLauncher; use tauri_plugin_deep_link::DeepLinkExt; -use tauri_plugin_window_state; use utils::logging::Type; /// A global singleton handle to the application. diff --git a/src-tauri/src/utils/autostart.rs b/src-tauri/src/utils/autostart.rs index e78cc3b8..565f7150 100644 --- a/src-tauri/src/utils/autostart.rs +++ b/src-tauri/src/utils/autostart.rs @@ -1,9 +1,10 @@ +#[cfg(target_os = "windows")] use anyhow::{anyhow, Result}; +#[cfg(target_os = "windows")] use log::info; -use std::{ - fs, - path::{Path, PathBuf}, -}; + +#[cfg(target_os = "windows")] +use std::{fs, path::Path, path::PathBuf}; /// Windows 下的开机启动文件夹路径 #[cfg(target_os = "windows")] @@ -25,6 +26,7 @@ pub fn get_startup_dir() -> Result { } /// 获取当前可执行文件路径 +#[cfg(target_os = "windows")] pub fn get_exe_path() -> Result { let exe_path = std::env::current_exe().map_err(|e| anyhow!("无法获取当前可执行文件路径: {}", e))?; @@ -98,17 +100,17 @@ pub fn is_shortcut_enabled() -> Result { } // 非 Windows 平台使用的空方法 -#[cfg(not(target_os = "windows"))] -pub fn create_shortcut() -> Result<()> { - Ok(()) -} +// #[cfg(not(target_os = "windows"))] +// pub fn create_shortcut() -> Result<()> { +// Ok(()) +// } -#[cfg(not(target_os = "windows"))] -pub fn remove_shortcut() -> Result<()> { - Ok(()) -} +// #[cfg(not(target_os = "windows"))] +// pub fn remove_shortcut() -> Result<()> { +// Ok(()) +// } -#[cfg(not(target_os = "windows"))] -pub fn is_shortcut_enabled() -> Result { - Ok(false) -} +// #[cfg(not(target_os = "windows"))] +// pub fn is_shortcut_enabled() -> Result { +// Ok(false) +// }