Skip to content

Commit 739cfc7

Browse files
committed
fix: 修复代码格式
1 parent 69dd53d commit 739cfc7

3 files changed

Lines changed: 40 additions & 16 deletions

File tree

src-tauri/src/env_providers/php.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ impl PhpEnvironmentProvider {
9292
.map_err(|e| format!("创建 HTTP 客户端失败: {}", e))?;
9393

9494
// Linux 使用 php-builder 仓库
95-
let repo_url = "https://api.github.com/repos/shivammathur/php-builder/releases?per_page=100";
95+
let repo_url =
96+
"https://api.github.com/repos/shivammathur/php-builder/releases?per_page=100";
9697

9798
info!("使用仓库: {}", repo_url);
9899

@@ -118,15 +119,19 @@ impl PhpEnvironmentProvider {
118119
for release in releases {
119120
if let Some(tag_name) = release["tag_name"].as_str() {
120121
// Linux 版本标签格式为纯版本号或 php-版本号
121-
let version = tag_name.trim_start_matches("php-").trim_start_matches("php_");
122+
let version = tag_name
123+
.trim_start_matches("php-")
124+
.trim_start_matches("php_");
122125

123126
if let Some(assets) = release["assets"].as_array() {
124127
for asset in assets {
125128
if let Some(name) = asset["name"].as_str() {
126129
// Linux: 匹配 ubuntu 和 debian 的 tar.xz 或 tar.zst 文件
127130
// 文件名格式: php_8.3+ubuntu22.04_arm64.tar.xz 或 php_8.3+debian12.tar.xz
128-
let is_compressed = name.ends_with(".tar.xz") || name.ends_with(".tar.zst");
129-
let is_php_package = name.starts_with("php_") || name.starts_with("php-");
131+
let is_compressed =
132+
name.ends_with(".tar.xz") || name.ends_with(".tar.zst");
133+
let is_php_package =
134+
name.starts_with("php_") || name.starts_with("php-");
130135
let is_not_debug = !name.contains("dbgsym");
131136

132137
// 匹配架构(如果文件名中包含架构信息)或默认 x86_64 包
@@ -145,7 +150,10 @@ impl PhpEnvironmentProvider {
145150
.unwrap_or("")
146151
.to_string();
147152

148-
info!("找到 PHP 版本: {} - {} - {}", version, name, download_url);
153+
info!(
154+
"找到 PHP 版本: {} - {} - {}",
155+
version, name, download_url
156+
);
149157

150158
php_releases.push(PhpRelease {
151159
version: version.to_string(),
@@ -449,7 +457,9 @@ impl EnvironmentProvider for PhpEnvironmentProvider {
449457
} else {
450458
"tar.gz"
451459
};
452-
let temp_file = self.install_dir.join(format!("php-{}.{}", version, file_ext));
460+
let temp_file = self
461+
.install_dir
462+
.join(format!("php-{}.{}", version, file_ext));
453463

454464
let should_download = if is_cdn_enabled() {
455465
let metadata = fetch_metadata_from_cdn("php").await;

src-tauri/src/env_providers/rust.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,7 @@ impl RustEnvironmentProvider {
338338
info!("合并 Rust 标准库到 rustc 目录");
339339

340340
// 查找所有 rust-std-* 目录
341-
let entries = fs::read_dir(install_path)
342-
.map_err(|e| format!("读取安装目录失败: {}", e))?;
341+
let entries = fs::read_dir(install_path).map_err(|e| format!("读取安装目录失败: {}", e))?;
343342

344343
for entry in entries.flatten() {
345344
let path = entry.path();
@@ -352,7 +351,8 @@ impl RustEnvironmentProvider {
352351
let std_rustlib_src = path.join("lib").join("rustlib");
353352

354353
// 目标路径: install_path/rustc/lib/rustlib/
355-
let rustc_rustlib_dst = install_path.join("rustc").join("lib").join("rustlib");
354+
let rustc_rustlib_dst =
355+
install_path.join("rustc").join("lib").join("rustlib");
356356

357357
if std_rustlib_src.exists() && rustc_rustlib_dst.exists() {
358358
// 遍历标准库中的所有目标平台
@@ -361,20 +361,26 @@ impl RustEnvironmentProvider {
361361
let std_target_path = std_entry.path();
362362
if std_target_path.is_dir() {
363363
if let Some(target_name) = std_target_path.file_name() {
364-
let dst_target_path = rustc_rustlib_dst.join(target_name);
364+
let dst_target_path =
365+
rustc_rustlib_dst.join(target_name);
365366

366367
// 如果目标路径不存在,创建它
367368
if !dst_target_path.exists() {
368-
fs::create_dir_all(&dst_target_path)
369-
.map_err(|e| format!("创建目标目录失败: {}", e))?;
369+
fs::create_dir_all(&dst_target_path).map_err(
370+
|e| format!("创建目标目录失败: {}", e),
371+
)?;
370372
}
371373

372374
// 复制 lib 目录
373375
let std_lib_src = std_target_path.join("lib");
374376
let dst_lib = dst_target_path.join("lib");
375377

376378
if std_lib_src.exists() {
377-
info!("复制标准库: {} -> {}", std_lib_src.display(), dst_lib.display());
379+
info!(
380+
"复制标准库: {} -> {}",
381+
std_lib_src.display(),
382+
dst_lib.display()
383+
);
378384
Self::copy_dir_all(&std_lib_src, &dst_lib)?;
379385
}
380386
}
@@ -398,7 +404,9 @@ impl RustEnvironmentProvider {
398404

399405
for entry in fs::read_dir(src).map_err(|e| format!("读取目录失败: {}", e))? {
400406
let entry = entry.map_err(|e| format!("读取条目失败: {}", e))?;
401-
let ty = entry.file_type().map_err(|e| format!("获取文件类型失败: {}", e))?;
407+
let ty = entry
408+
.file_type()
409+
.map_err(|e| format!("获取文件类型失败: {}", e))?;
402410
let src_path = entry.path();
403411
let dst_path = dst.join(entry.file_name());
404412

src-tauri/src/plugins/rust.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ impl LanguagePlugin for RustPlugin {
5959

6060
// 默认命令
6161
#[cfg(target_os = "windows")]
62-
return vec!["/c".to_string(), format!("rustc {} -o main.exe && main.exe", file_path)];
62+
return vec![
63+
"/c".to_string(),
64+
format!("rustc {} -o main.exe && main.exe", file_path),
65+
];
6366

6467
#[cfg(not(target_os = "windows"))]
65-
vec!["-c".to_string(), format!("rustc {} -o /tmp/main && /tmp/main", file_path)]
68+
vec![
69+
"-c".to_string(),
70+
format!("rustc {} -o /tmp/main && /tmp/main", file_path),
71+
]
6672
}
6773

6874
fn get_command(

0 commit comments

Comments
 (0)