Skip to content

Commit 972a81c

Browse files
committed
fix (core): 修复 Pre-execution 未反馈错误
1 parent 3b3c80f commit 972a81c

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

src-tauri/src/plugins/mod.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ pub trait LanguagePlugin: Send + Sync {
307307
}
308308

309309
fn execute_cross_platform_command(&self, command: &str) -> Result<(), String> {
310+
info!("执行命令: {}", command);
311+
310312
let output = if cfg!(target_os = "windows") {
311313
std::process::Command::new("cmd")
312314
.args(["/C", command])
@@ -319,11 +321,26 @@ pub trait LanguagePlugin: Send + Sync {
319321

320322
let output = output.map_err(|e| format!("执行命令失败: {}", e))?;
321323

324+
debug!("命令退出状态: {:?}", output.status);
325+
debug!("命令标准输出: {}", String::from_utf8_lossy(&output.stdout));
326+
debug!("命令标准错误: {}", String::from_utf8_lossy(&output.stderr));
327+
322328
if !output.status.success() {
323-
return Err(format!(
324-
"命令执行失败: {}",
325-
String::from_utf8_lossy(&output.stderr)
326-
));
329+
let stderr = String::from_utf8_lossy(&output.stderr);
330+
let stdout = String::from_utf8_lossy(&output.stdout);
331+
332+
let error_msg = if !stderr.is_empty() {
333+
stderr.to_string()
334+
} else if !stdout.is_empty() {
335+
stdout.to_string()
336+
} else {
337+
format!(
338+
"命令执行失败,退出代码: {}",
339+
output.status.code().unwrap_or(-1)
340+
)
341+
};
342+
343+
return Err(format!("命令执行失败: {}", error_msg));
327344
}
328345

329346
Ok(())

src/composables/useCodeMirrorEditor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export function useCodeMirrorEditor(props: Props)
184184
return StreamLanguage.define(clojure)
185185
case 'ruby':
186186
return StreamLanguage.define(ruby)
187+
case 'typescript':
187188
case 'typescript-nodejs':
188189
return javascript({typescript: true})
189190
default:

0 commit comments

Comments
 (0)