mirror of
https://github.com/laurent22/joplin.git
synced 2026-06-18 20:16:34 +02:00
Register to handle joplin:// links
This commit is contained in:
1 parent
11cf8474f7
commit
b17d8bc533
2 files changed
+21
-1
No files matched your search
@@ -320,12 +320,16 @@ export default class ElectronAppWrapper {
|
||||
}
|
||||
|
||||
// Someone tried to open a second instance - focus our window instead
|
||||
this.electronApp_.on('second-instance', () => {
|
||||
this.electronApp_.on('second-instance', (_e: any, argv: string[]) => {
|
||||
const win = this.window();
|
||||
if (!win) return;
|
||||
if (win.isMinimized()) win.restore();
|
||||
win.show();
|
||||
win.focus();
|
||||
if (process.platform !== 'darwin') {
|
||||
const url = argv.find((arg) => arg.startsWith('joplin://'));
|
||||
if (!!url) this.onUrl(url)
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
@@ -352,6 +356,14 @@ export default class ElectronAppWrapper {
|
||||
this.electronApp_.on('activate', () => {
|
||||
this.win_.show();
|
||||
});
|
||||
|
||||
this.electronApp_.on('open-url', (_event: any, url: string) => {
|
||||
this.onUrl(url);
|
||||
});
|
||||
}
|
||||
|
||||
async onUrl(url: string) {
|
||||
console.log(`on url: ${url}`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,6 +36,14 @@ const env = envFromArgs(process.argv);
|
||||
const profilePath = profileFromArgs(process.argv);
|
||||
const isDebugMode = !!process.argv && process.argv.indexOf('--debug') >= 0;
|
||||
|
||||
if (env === 'dev' && process.platform === 'win32') {
|
||||
electronApp.setAsDefaultProtocolClient('joplin', process.execPath, [
|
||||
resolve(process.argv[1])
|
||||
]);
|
||||
} else {
|
||||
electronApp.setAsDefaultProtocolClient('joplin');
|
||||
}
|
||||
|
||||
const wrapper = new ElectronAppWrapper(electronApp, env, profilePath, isDebugMode);
|
||||
|
||||
initBridge(wrapper);
|
||||
|
||||
Reference in new issue
Block a user