Skip to content

Build your personal knowledge base with Trilium Notes

open directory

SiriusXTe66b865cd637
diff --git a/src/public/app/services/open.js b/src/public/app/services/open.js
index b3a1ae08b9..9ecab753fd 100644
--- a/src/public/app/services/open.js
+++ b/src/public/app/services/open.js
@@ -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
}
diff --git a/src/public/app/widgets/dialogs/about.js b/src/public/app/widgets/dialogs/about.js
index 6b89e8b6ad..6e08cf4029 100644
--- a/src/public/app/widgets/dialogs/about.js
+++ b/src/public/app/widgets/dialogs/about.js
@@ -2,6 +2,8 @@ import server from "../../services/server.js";
import utils from "../../services/utils.js";
import { t } from "../../services/i18n.js";
import BasicWidget from "../basic_widget.js";
+import openService from "../../services/open.js";
+
const TPL = `
<div class="about-dialog modal fade mx-auto" tabindex="-1" role="dialog">
@@ -74,10 +76,11 @@ export default class AboutDialog extends BasicWidget {
this.$buildRevision.attr('href', `https://github.com/TriliumNext/Notes/commit/${appInfo.buildRevision}`);
if (utils.isElectron()) {
this.$dataDirectory.html($('<a></a>', {
- href: 'file:///' + appInfo.dataDirectory,
text: appInfo.dataDirectory,
- target: '_blank'
}));
+ this.$dataDirectory.find("a").on('click', () => {
+ openService.openDirectory(appInfo.dataDirectory);
+ })
} else {
this.$dataDirectory.text(appInfo.dataDirectory);
}