mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-02-26 01:51:43 -08:00
Update setupViewFileProtocol.ts
This commit is contained in:
parent
31b4319655
commit
93a1427ebe
1 changed files with 7 additions and 5 deletions
|
|
@ -17,13 +17,15 @@ import { INewWindowAction } from './interface';
|
|||
export function handleOpenFileExternalLink(nextUrl: string): INewWindowAction | undefined {
|
||||
const nativeService = container.get<INativeService>(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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue