浏览代码

fix: open file

GyDi 2 年之前
父节点
当前提交
eea9cb7c5b
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src-tauri/src/utils/help.rs

+ 5 - 1
src-tauri/src/utils/help.rs

@@ -50,9 +50,13 @@ pub fn open_file(path: PathBuf) -> Result<()> {
     #[cfg(target_os = "windows")]
     {
       use std::os::windows::process::CommandExt;
-      command = command.creation_flags(0x08000000);
+      if let Err(err) = command.creation_flags(0x08000000).arg(&path).spawn() {
+        log::error!(target: "app", "failed to open with VScode `{err}`");
+        open::that(path)?;
+      }
     }
 
+    #[cfg(not(target_os = "windows"))]
     if let Err(err) = command.arg(&path).spawn() {
       log::error!(target: "app", "failed to open with VScode `{err}`");
       open::that(path)?;