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