mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 11:39:01 +01:00 
			
		
		
		
	Merge pull request #389 from SiriusXT/open_in_file_manager_of_data
Open in file manager of Trilium's data directory
This commit is contained in:
		
						commit
						7a11f9aaff
					
				| @ -166,6 +166,23 @@ function getHost() { | |||||||
|     return `${url.protocol}//${url.hostname}:${url.port}`; |     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.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 { | export default { | ||||||
|     download, |     download, | ||||||
|     downloadFileNote, |     downloadFileNote, | ||||||
| @ -176,4 +193,5 @@ export default { | |||||||
|     openAttachmentExternally, |     openAttachmentExternally, | ||||||
|     openNoteCustom, |     openNoteCustom, | ||||||
|     openAttachmentCustom, |     openAttachmentCustom, | ||||||
|  |     openDirectory | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,6 +2,8 @@ import server from "../../services/server.js"; | |||||||
| import utils from "../../services/utils.js"; | import utils from "../../services/utils.js"; | ||||||
| import { t } from "../../services/i18n.js"; | import { t } from "../../services/i18n.js"; | ||||||
| import BasicWidget from "../basic_widget.js"; | import BasicWidget from "../basic_widget.js"; | ||||||
|  | import openService from "../../services/open.js"; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| const TPL = ` | const TPL = ` | ||||||
| <div class="about-dialog modal fade mx-auto" tabindex="-1" role="dialog"> | <div class="about-dialog modal fade mx-auto" tabindex="-1" role="dialog"> | ||||||
| @ -72,8 +74,19 @@ export default class AboutDialog extends BasicWidget { | |||||||
|         this.$buildDate.text(appInfo.buildDate); |         this.$buildDate.text(appInfo.buildDate); | ||||||
|         this.$buildRevision.text(appInfo.buildRevision); |         this.$buildRevision.text(appInfo.buildRevision); | ||||||
|         this.$buildRevision.attr('href', `https://github.com/TriliumNext/Notes/commit/${appInfo.buildRevision}`); |         this.$buildRevision.attr('href', `https://github.com/TriliumNext/Notes/commit/${appInfo.buildRevision}`); | ||||||
|  |         if (utils.isElectron()) { | ||||||
|  |             this.$dataDirectory.html($('<a></a>', { | ||||||
|  |                 href: '#', | ||||||
|  |                 text: appInfo.dataDirectory, | ||||||
|  |             })); | ||||||
|  |             this.$dataDirectory.find("a").on('click', (event) => { | ||||||
|  |                 event.preventDefault(); | ||||||
|  |                 openService.openDirectory(appInfo.dataDirectory); | ||||||
|  |             }) | ||||||
|  |         } else { | ||||||
|             this.$dataDirectory.text(appInfo.dataDirectory); |             this.$dataDirectory.text(appInfo.dataDirectory); | ||||||
|         } |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     async openAboutDialogEvent() { |     async openAboutDialogEvent() { | ||||||
|         await this.refresh(); |         await this.refresh(); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran