From c2f850532a69fcbb75846f798dcb33a7a5b846a6 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Fri, 27 Mar 2026 13:17:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=9B=E5=BB=BA=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=9A=84=E5=90=8E=E7=AB=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/commands/project_boot.rs | 45 +++++++++++++++++-- src-tauri/src/commands/windows.rs | 12 +++-- .../shadcn/create-project-dialog.tsx | 6 +-- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/commands/project_boot.rs b/src-tauri/src/commands/project_boot.rs index a785676..20bd145 100644 --- a/src-tauri/src/commands/project_boot.rs +++ b/src-tauri/src/commands/project_boot.rs @@ -65,7 +65,20 @@ pub async fn create_shadcn_project( ]); cmd.current_dir(&target_dir); + // Log the full command for debugging + let cmd_display = format!( + "{} {} shadcn@latest init -n {} -t {} -p {} -y (cwd={})", + program, + prefix_args.join(" "), + project_name, + template, + preset_code, + target_dir + ); + eprintln!("[ProjectBoot] executing: {cmd_display}"); + let output = cmd.output().await.map_err(|e| { + eprintln!("[ProjectBoot] spawn error: {e}"); if e.kind() == std::io::ErrorKind::NotFound { AppCommandError::dependency_missing(format!( "{program} is not installed. Please install Node.js first." @@ -78,10 +91,36 @@ pub async fn create_shadcn_project( } })?; + let stdout = String::from_utf8_lossy(&output.stdout).to_string(); + let stderr = String::from_utf8_lossy(&output.stderr).to_string(); + + eprintln!( + "[ProjectBoot] exit={} stdout_len={} stderr_len={}", + output.status, + stdout.len(), + stderr.len() + ); + if !stdout.is_empty() { + eprintln!("[ProjectBoot] stdout: {stdout}"); + } + if !stderr.is_empty() { + eprintln!("[ProjectBoot] stderr: {stderr}"); + } + if !output.status.success() { - let stderr = String::from_utf8_lossy(&output.stderr).to_string(); - let stdout = String::from_utf8_lossy(&output.stdout).to_string(); - let detail = if stderr.is_empty() { stdout } else { stderr }; + let mut detail = String::new(); + if !stderr.is_empty() { + detail.push_str(&stderr); + } + if !stdout.is_empty() { + if !detail.is_empty() { + detail.push('\n'); + } + detail.push_str(&stdout); + } + if detail.is_empty() { + detail = format!("Command exited with status: {}", output.status); + } return Err(AppCommandError::external_command( "Project creation command failed", detail, diff --git a/src-tauri/src/commands/windows.rs b/src-tauri/src/commands/windows.rs index 394aab6..3c1f779 100644 --- a/src-tauri/src/commands/windows.rs +++ b/src-tauri/src/commands/windows.rs @@ -207,6 +207,9 @@ pub async fn open_folder_window( if let Some(w) = app.get_webview_window("welcome") { let _ = w.close(); } + if let Some(w) = app.get_webview_window("project-boot") { + let _ = w.close(); + } return Ok(()); } @@ -220,11 +223,12 @@ pub async fn open_folder_window( .map_err(|e| AppCommandError::window("Failed to open folder window", e.to_string()))?; ensure_windows_undecorated(&folder_window); - // Close welcome window + // Close welcome and project-boot windows if let Some(w) = app.get_webview_window("welcome") { - w.close().map_err(|e| { - AppCommandError::window("Failed to close welcome window", e.to_string()) - })?; + let _ = w.close(); + } + if let Some(w) = app.get_webview_window("project-boot") { + let _ = w.close(); } Ok(()) } diff --git a/src/components/project-boot/shadcn/create-project-dialog.tsx b/src/components/project-boot/shadcn/create-project-dialog.tsx index ff94d64..b5fd662 100644 --- a/src/components/project-boot/shadcn/create-project-dialog.tsx +++ b/src/components/project-boot/shadcn/create-project-dialog.tsx @@ -23,6 +23,7 @@ import { } from "@/components/ui/dialog" import { openFileDialog } from "@/lib/platform" import { createShadcnProject, openFolderWindow } from "@/lib/api" +import { toErrorMessage } from "@/lib/app-error" import { FRAMEWORK_OPTIONS, PACKAGE_MANAGER_OPTIONS } from "./constants" interface CreateProjectDialogProps { @@ -67,10 +68,7 @@ export function CreateProjectDialog({ resetForm() await openFolderWindow(projectPath) } catch (err) { - const message = - err && typeof err === "object" && "message" in err - ? (err as { message: string }).message - : String(err) + const message = toErrorMessage(err) setError(message) toast.error(t("toasts.createFailed"), { description: message }) } finally {