Ver Fonte

Linux平台的构建

黄中银 há 2 semanas atrás
pai
commit
350587ac5c
1 ficheiros alterados com 8 adições e 8 exclusões
  1. 8 8
      src-tauri/src/commands/install.rs

+ 8 - 8
src-tauri/src/commands/install.rs

@@ -1,31 +1,31 @@
 #[cfg(target_os = "windows")]
 use crate::commands::config::{get_git_mirror_config, get_nodejs_mirror_config};
 use crate::commands::AppState;
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "windows", target_os = "linux"))]
 use crate::utils::http::get_client;
 #[cfg(any(target_os = "windows", target_os = "linux"))]
 use crate::utils::http::HttpRequest;
 use crate::utils::shell::run_shell_hidden;
 #[cfg(target_os = "windows")]
 use crate::utils::shell::{run_program, CommandOptions};
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "windows", target_os = "linux"))]
 use futures::StreamExt;
 use serde::{Deserialize, Serialize};
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "windows", target_os = "linux"))]
 use std::io::Write;
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "windows", target_os = "linux"))]
 use std::path::Path;
 use tauri::{Emitter, State};
 
 /// 安装错误,包含 i18nKey 用于前端翻译
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "windows", target_os = "linux"))]
 #[derive(Debug, Clone)]
 pub struct InstallError {
     pub i18n_key: String,
     pub detail: Option<String>,
 }
 
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "windows", target_os = "linux"))]
 impl InstallError {
     pub fn new(i18n_key: &str) -> Self {
         Self {
@@ -50,7 +50,7 @@ impl InstallError {
     }
 }
 
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "windows", target_os = "linux"))]
 impl std::fmt::Display for InstallError {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         write!(f, "{}", self.to_message())
@@ -59,7 +59,7 @@ impl std::fmt::Display for InstallError {
 
 /// 下载文件并报告进度(支持断点续传)
 /// progress_callback: (downloaded_bytes, total_bytes, percent)
-#[cfg(target_os = "windows")]
+#[cfg(any(target_os = "windows", target_os = "linux"))]
 async fn download_file_with_progress<F>(
     url: &str,
     dest_path: &Path,