From 93a1427ebef42229cbbf31ba7193f9cd9c63cf74 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Wed, 21 Jun 2023 14:33:16 +0800 Subject: [PATCH] Update setupViewFileProtocol.ts --- src/services/view/setupViewFileProtocol.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/services/view/setupViewFileProtocol.ts b/src/services/view/setupViewFileProtocol.ts index fdc2f52a..93866801 100644 --- a/src/services/view/setupViewFileProtocol.ts +++ b/src/services/view/setupViewFileProtocol.ts @@ -17,13 +17,15 @@ import { INewWindowAction } from './interface'; export function handleOpenFileExternalLink(nextUrl: string): INewWindowAction | undefined { const nativeService = container.get(serviceIdentifier.NativeService); const absoluteFilePath = nativeService.formatFileUrlToAbsolutePath(nextUrl); - const fileExists = fs.existsSync(absoluteFilePath); - if (fileExists) { + const fileStat = fs.statSync(absoluteFilePath); + if (fileStat.isDirectory()) { + void shell.openExternal(absoluteFilePath); + } else if (fileStat.isFile()) { void shell.openPath(absoluteFilePath); - return { - action: 'deny', - }; } + return { + action: 'deny', + }; } /* eslint-disable n/no-callback-literal */