|
|
@@ -1,5 +1,5 @@
|
|
|
use crate::commands::AppState;
|
|
|
-use crate::commands::config::{get_git_mirror_config, get_nodejs_mirror_config, get_vscode_mirror_config};
|
|
|
+use crate::commands::config::{get_git_mirror_config, get_nodejs_mirror_config};
|
|
|
use crate::utils::shell::{run_program, run_shell_hidden, CommandOptions};
|
|
|
use futures::StreamExt;
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
@@ -543,10 +543,6 @@ where
|
|
|
"software": "VS Code"
|
|
|
})));
|
|
|
|
|
|
- // 获取镜像配置
|
|
|
- let mirror_config = get_vscode_mirror_config().await;
|
|
|
- let mirror = mirror_config.mirror.as_str();
|
|
|
-
|
|
|
let client = reqwest::Client::new();
|
|
|
|
|
|
// 从官方 API 获取下载地址
|
|
|
@@ -559,24 +555,10 @@ where
|
|
|
|
|
|
let update_info: serde_json::Value = update_response.json().await.map_err(|e| e.to_string())?;
|
|
|
|
|
|
- let official_url = update_info.get("url")
|
|
|
+ let download_url = update_info.get("url")
|
|
|
.and_then(|v| v.as_str())
|
|
|
.ok_or("Failed to get VS Code download URL")?;
|
|
|
|
|
|
- // 根据镜像配置决定下载地址
|
|
|
- let download_url: String = if mirror == "azure-china" {
|
|
|
- // 国内镜像:将官方下载地址中的域名替换为 vscode.cdn.azure.cn
|
|
|
- if let Ok(mut url) = reqwest::Url::parse(official_url) {
|
|
|
- let _ = url.set_host(Some("vscode.cdn.azure.cn"));
|
|
|
- url.to_string()
|
|
|
- } else {
|
|
|
- official_url.to_string()
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 官方源:直接使用官方 API 返回的下载地址
|
|
|
- official_url.to_string()
|
|
|
- };
|
|
|
-
|
|
|
let temp_dir = std::env::temp_dir();
|
|
|
let exe_path = temp_dir.join("VSCodeSetup.exe");
|
|
|
|
|
|
@@ -659,10 +641,6 @@ where
|
|
|
"software": "VS Code"
|
|
|
})));
|
|
|
|
|
|
- // 获取镜像配置
|
|
|
- let mirror_config = get_vscode_mirror_config().await;
|
|
|
- let mirror = mirror_config.mirror.as_str();
|
|
|
-
|
|
|
let client = reqwest::Client::new();
|
|
|
|
|
|
// 从官方 API 获取下载地址
|
|
|
@@ -675,24 +653,10 @@ where
|
|
|
|
|
|
let update_info: serde_json::Value = update_response.json().await.map_err(|e| e.to_string())?;
|
|
|
|
|
|
- let official_url = update_info.get("url")
|
|
|
+ let download_url = update_info.get("url")
|
|
|
.and_then(|v| v.as_str())
|
|
|
.ok_or("Failed to get VS Code download URL")?;
|
|
|
|
|
|
- // 根据镜像配置决定下载地址
|
|
|
- let download_url: String = if mirror == "azure-china" {
|
|
|
- // 国内镜像:将官方下载地址中的域名替换为 vscode.cdn.azure.cn
|
|
|
- if let Ok(mut url) = reqwest::Url::parse(official_url) {
|
|
|
- let _ = url.set_host(Some("vscode.cdn.azure.cn"));
|
|
|
- url.to_string()
|
|
|
- } else {
|
|
|
- official_url.to_string()
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 官方源:直接使用官方 API 返回的下载地址
|
|
|
- official_url.to_string()
|
|
|
- };
|
|
|
-
|
|
|
let temp_dir = std::env::temp_dir();
|
|
|
let deb_path = temp_dir.join("code.deb");
|
|
|
|