fix: clippy lint

This commit is contained in:
Slinetrac
2025-11-09 23:23:03 +08:00
parent 221a1e89eb
commit 0dcdd7fed6
8 changed files with 23 additions and 18 deletions

View File

@@ -4,7 +4,7 @@ use crate::cmd::CmdResult;
#[cfg(windows)] #[cfg(windows)]
mod platform { mod platform {
use crate::cmd::CmdResult; use crate::cmd::CmdResult;
use crate::cmd::StringifyErr; use crate::cmd::StringifyErr as _;
use crate::core::win_uwp; use crate::core::win_uwp;
pub fn invoke_uwp_tool() -> CmdResult { pub fn invoke_uwp_tool() -> CmdResult {

View File

@@ -520,7 +520,7 @@ impl EventDrivenProxyManager {
use crate::utils::dirs; use crate::utils::dirs;
#[allow(unused_imports)] // creation_flags必须 #[allow(unused_imports)] // creation_flags必须
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt as _;
use tokio::process::Command; use tokio::process::Command;
let binary_path = match dirs::service_path() { let binary_path = match dirs::service_path() {

View File

@@ -37,7 +37,7 @@ async fn uninstall_service() -> Result<()> {
use deelevate::{PrivilegeLevel, Token}; use deelevate::{PrivilegeLevel, Token};
use runas::Command as RunasCommand; use runas::Command as RunasCommand;
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt as _;
let binary_path = dirs::service_path()?; let binary_path = dirs::service_path()?;
let uninstall_path = binary_path.with_file_name("clash-verge-service-uninstall.exe"); let uninstall_path = binary_path.with_file_name("clash-verge-service-uninstall.exe");
@@ -72,7 +72,7 @@ async fn install_service() -> Result<()> {
use deelevate::{PrivilegeLevel, Token}; use deelevate::{PrivilegeLevel, Token};
use runas::Command as RunasCommand; use runas::Command as RunasCommand;
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt as _;
let binary_path = dirs::service_path()?; let binary_path = dirs::service_path()?;
let install_path = binary_path.with_file_name("clash-verge-service-install.exe"); let install_path = binary_path.with_file_name("clash-verge-service-install.exe");

View File

@@ -59,7 +59,7 @@ async fn execute_sysproxy_command(args: Vec<std::string::String>) -> Result<()>
use crate::utils::dirs; use crate::utils::dirs;
use anyhow::bail; use anyhow::bail;
#[allow(unused_imports)] // Required for .creation_flags() method #[allow(unused_imports)] // Required for .creation_flags() method
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt as _;
use tokio::process::Command; use tokio::process::Command;
let binary_path = dirs::service_path()?; let binary_path = dirs::service_path()?;

View File

@@ -11,19 +11,14 @@ mod module;
mod process; mod process;
pub mod utils; pub mod utils;
use crate::constants::files; use crate::constants::files;
#[cfg(target_os = "macos")]
use crate::module::lightweight;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use crate::utils::linux; use crate::utils::linux;
#[cfg(target_os = "macos")]
use crate::utils::window_manager::WindowManager;
use crate::{ use crate::{
core::{EventDrivenProxyManager, handle, hotkey}, core::{EventDrivenProxyManager, handle},
process::AsyncHandler, process::AsyncHandler,
utils::{resolve, server}, utils::{resolve, server},
}; };
use anyhow::Result; use anyhow::Result;
use config::Config;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use rust_i18n::i18n; use rust_i18n::i18n;
use tauri::{AppHandle, Manager as _}; use tauri::{AppHandle, Manager as _};
@@ -269,8 +264,18 @@ pub fn run() {
.invoke_handler(app_init::generate_handlers()); .invoke_handler(app_init::generate_handlers());
mod event_handlers { mod event_handlers {
use super::*; #[cfg(target_os = "macos")]
use crate::core::handle; use crate::module::lightweight;
#[cfg(target_os = "macos")]
use crate::utils::window_manager::WindowManager;
use crate::{
config::Config,
core::{self, handle, hotkey},
logging,
process::AsyncHandler,
utils::logging::Type,
};
use tauri::AppHandle;
pub fn handle_ready_resumed(_app_handle: &AppHandle) { pub fn handle_ready_resumed(_app_handle: &AppHandle) {
if handle::Handle::global().is_exiting() { if handle::Handle::global().is_exiting() {

View File

@@ -1,4 +1,4 @@
use tauri::Manager; use tauri::Manager as _;
use windows_sys::Win32::{ use windows_sys::Win32::{
Foundation::{HWND, LPARAM, LRESULT, WPARAM}, Foundation::{HWND, LPARAM, LRESULT, WPARAM},
UI::WindowsAndMessaging::{ UI::WindowsAndMessaging::{

View File

@@ -4,7 +4,7 @@ use crate::{logging, utils::logging::Type};
use anyhow::{Result, anyhow}; use anyhow::{Result, anyhow};
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
use std::{os::windows::process::CommandExt, path::Path, path::PathBuf}; use std::{os::windows::process::CommandExt as _, path::Path, path::PathBuf};
/// Windows 下的开机启动文件夹路径 /// Windows 下的开机启动文件夹路径
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
@@ -37,7 +37,7 @@ pub fn get_exe_path() -> Result<PathBuf> {
/// 创建快捷方式 /// 创建快捷方式
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub async fn create_shortcut() -> Result<()> { pub async fn create_shortcut() -> Result<()> {
use crate::utils::dirs::PathBufExec; use crate::utils::dirs::PathBufExec as _;
let exe_path = get_exe_path()?; let exe_path = get_exe_path()?;
let startup_dir = get_startup_dir()?; let startup_dir = get_startup_dir()?;
@@ -90,7 +90,7 @@ pub async fn create_shortcut() -> Result<()> {
/// 删除快捷方式 /// 删除快捷方式
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub async fn remove_shortcut() -> Result<()> { pub async fn remove_shortcut() -> Result<()> {
use crate::utils::dirs::PathBufExec; use crate::utils::dirs::PathBufExec as _;
let startup_dir = get_startup_dir()?; let startup_dir = get_startup_dir()?;
let old_shortcut_path = startup_dir.join("Clash-Verge.lnk"); let old_shortcut_path = startup_dir.join("Clash-Verge.lnk");

View File

@@ -466,7 +466,7 @@ pub async fn init_resources() -> Result<()> {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub fn init_scheme() -> Result<()> { pub fn init_scheme() -> Result<()> {
use tauri::utils::platform::current_exe; use tauri::utils::platform::current_exe;
use winreg::{RegKey, enums::*}; use winreg::{RegKey, enums::HKEY_CURRENT_USER};
let app_exe = current_exe()?; let app_exe = current_exe()?;
let app_exe = dunce::canonicalize(app_exe)?; let app_exe = dunce::canonicalize(app_exe)?;