fix: windows build error

This commit is contained in:
Tunglies 2025-04-16 16:52:22 +08:00
parent 2a908b20eb
commit 3488d89b7d
2 changed files with 10 additions and 11 deletions

View File

@ -1,8 +1,12 @@
use crate::{config::Config, utils::dirs::app_socket_path}; use crate::config::Config;
#[cfg(unix)]
use crate::utils::dirs::app_socket_path;
use mihomo_api; use mihomo_api;
use once_cell::sync::{Lazy, OnceCell}; use once_cell::sync::{Lazy, OnceCell};
use std::sync::Mutex; use std::sync::Mutex;
use tauri::http::{HeaderMap, HeaderValue}; use tauri::http::HeaderMap;
#[cfg(target_os = "macos")]
use tauri::http::HeaderValue;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
use tokio_tungstenite::tungstenite::http; use tokio_tungstenite::tungstenite::http;
@ -70,7 +74,7 @@ impl MihomoManager {
#[cfg(unix)] #[cfg(unix)]
let socket_path = app_socket_path().unwrap(); let socket_path = app_socket_path().unwrap();
#[cfg(windows)] #[cfg(windows)]
let socket_path = r"\\.\pipe\mihomo"; let socket_path = r"\\.\pipe\mihomo".to_string();
socket_path socket_path
} }
} }

View File

@ -1,23 +1,18 @@
use crate::{model::E, sock}; use crate::model::E;
use hyper::Method; use hyper::Method;
use serde_json::Value; use serde_json::Value;
use tokio_util::codec::{Framed, LinesCodec}; use tokio_util::codec::{Framed, LinesCodec};
use std::{sync::Arc, time::Duration}; use std::time::Duration;
use tokio::{ use tokio::time::timeout;
time::timeout,
sync::Mutex,
};
use futures::{SinkExt, StreamExt}; use futures::{SinkExt, StreamExt};
use tokio::net::windows::named_pipe::ClientOptions; use tokio::net::windows::named_pipe::ClientOptions;
pub struct WindowsClient { pub struct WindowsClient {
lock: Arc<Mutex<()>>,
} }
impl WindowsClient { impl WindowsClient {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
lock: Arc::new(Mutex::new(())),
} }
} }