mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 15:25:51 +01:00
open directory
This commit is contained in:
@@ -72,7 +72,7 @@ async function openCustom(type, entityId, mime) {
|
||||
const terminal = terminals[index];
|
||||
if (!terminal) {
|
||||
console.error('Open Note custom: No terminal found!');
|
||||
open(getFileUrl(entityId), {url: true});
|
||||
open(getFileUrl(type, entityId), {url: true});
|
||||
return;
|
||||
}
|
||||
exec(`which ${terminal}`, (error, stdout, stderr) => {
|
||||
@@ -166,6 +166,26 @@ function getHost() {
|
||||
return `${url.protocol}//${url.hostname}:${url.port}`;
|
||||
}
|
||||
|
||||
async function openDirectory(directory) {
|
||||
try {
|
||||
if (utils.isElectron()) {
|
||||
const electron = utils.dynamicRequire('electron');
|
||||
const res = await electron.shell.openPath(directory);
|
||||
if (res) {
|
||||
console.error('Failed to open directory:', res);
|
||||
} else {
|
||||
console.log('Directory opened successfully.');
|
||||
}
|
||||
} else {
|
||||
console.error('Not running in an Electron environment.');
|
||||
}
|
||||
} catch (err) {
|
||||
// Handle file system errors (e.g. path does not exist or is inaccessible)
|
||||
console.error('Error:', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
download,
|
||||
downloadFileNote,
|
||||
@@ -176,4 +196,5 @@ export default {
|
||||
openAttachmentExternally,
|
||||
openNoteCustom,
|
||||
openAttachmentCustom,
|
||||
openDirectory
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user