From 36b77ce32b8c89465536765fe1b4931899fb354c Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 12 Jan 2025 12:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E4=B8=80=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B=E6=89=93=E5=BC=80=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E5=8D=B4=E6=89=93=E5=BC=80=E5=BA=94=E7=94=A8=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/item/index.ts | 4 +++- rust/windows.rs | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/electron/main/item/index.ts b/electron/main/item/index.ts index e626875..a99ceb4 100644 --- a/electron/main/item/index.ts +++ b/electron/main/item/index.ts @@ -323,12 +323,14 @@ function updateOpenInfo(type: string, id: number) { */ function run( type: string, - operation: "open" | "runas" | "openFileLocation", + operation: "open" | "runas" | "openFileLocation" | "explore", item: Item ) { if (item.data) { if (operation === "open" && item.data.runAsAdmin) { operation = "runas"; + } else if (operation === "open" && item.type === 1) { + operation = "explore"; } // 更新打开信息 updateOpenInfo(type, item.id); diff --git a/rust/windows.rs b/rust/windows.rs index 98f7e78..9bff9ef 100644 --- a/rust/windows.rs +++ b/rust/windows.rs @@ -729,6 +729,8 @@ pub fn shell_execute( operation = String::from("open"); } } + // 是否是打开文件夹 + let is_dir = operation == "explore"; // dir let dir = start_location.unwrap_or_else(|| { // 判断是否是文件夹 @@ -752,8 +754,18 @@ pub fn shell_execute( let params = PCWSTR(params.as_ptr()); let dir = PCWSTR(dir.as_ptr()); unsafe { - // execute - ShellExecuteW(None, operation, file, params, dir, SW_SHOWDEFAULT); + if is_dir { + ShellExecuteW( + None, + w!("open"), + w!("explorer.exe"), + file, + None, + SW_SHOWDEFAULT, + ); + } else { + ShellExecuteW(None, operation, file, params, dir, SW_SHOWDEFAULT); + } } }); }