修复同一目录下打开文件夹却打开应用程序的问题。

This commit is contained in:
unknown 2025-01-12 12:08:37 +08:00
parent d51a5404ee
commit 36b77ce32b
2 changed files with 17 additions and 3 deletions

View File

@ -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);

View File

@ -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);
}
}
});
}