mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
open directory
This commit is contained in:
parent
bc4444d132
commit
e66b865cd6
@ -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
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user