From 7c7bea5e3a0a1c98241e379c6a23c18871a0c843 Mon Sep 17 00:00:00 2001 From: SnnBcd xt <1160925501@qq.com> Date: Tue, 16 May 2023 14:01:55 +0000 Subject: [PATCH] Open notes with custom software. --- src/public/app/services/open.js | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/public/app/services/open.js b/src/public/app/services/open.js index fa5959642..9d6f3c931 100644 --- a/src/public/app/services/open.js +++ b/src/public/app/services/open.js @@ -55,18 +55,15 @@ async function openNoteCustom(noteId, mime) { const platform = process.platform; if (platform === 'linux') { const terminals = ['gnome-terminal', 'konsole', 'xterm', 'xfce4-terminal', 'mate-terminal', 'rxvt', 'terminator', 'terminology']; - let foundTerminal = false; - let availableTerminal = null; const openFileWithTerminal = (terminal) => { const command = `${terminal} -e 'mimeopen -d "${filePath}"'`; - console.log(`Open Note custom: ${command}. `); + console.log(`Open Note custom: ${command} `); exec(command, (error, stdout, stderr) => { if (error) { console.error(`Open Note custom: Failed to open file with ${terminal}: ${error}`); searchTerminal(terminals.indexOf(terminal) + 1); } else { - console.log(`Open Note custom: File opened with ${terminal}. `); - console.log(`Open Note custom: ${stdout}. `); + console.log(`Open Note custom: File opened with ${terminal}. ${stdout}`); } }); }; @@ -79,11 +76,7 @@ async function openNoteCustom(noteId, mime) { } exec(`which ${terminal}`, (error, stdout, stderr) => { if (stdout.trim()) { - foundTerminal = true; - availableTerminal = terminal; - } - if (foundTerminal) { - openFileWithTerminal(availableTerminal); + openFileWithTerminal(terminal); } else { searchTerminal(index + 1); } @@ -108,15 +101,6 @@ async function openNoteCustom(noteId, mime) { open(getFileUrl(noteId), { url: true }); } } - else { - // allow browser to handle opening common file - if (mime === "application/pdf" || mime.startsWith("image") || mime.startsWith("audio") || mime.startsWith("video")) { - window.open(getOpenFileUrl(noteId)); - } - else { - window.location.href = getFileUrl(noteId); - } - } } function downloadNoteRevision(noteId, noteRevisionId) {