mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 21:49:03 +00:00
tray: open on startup, handle notion:// protocol
This commit is contained in:
parent
e761b309bf
commit
97ef140789
@ -44,6 +44,7 @@ export default async function (api, db) {
|
|||||||
await web.whenReady([topbarSelector, topbarActionsSelector]);
|
await web.whenReady([topbarSelector, topbarActionsSelector]);
|
||||||
const $topbar = document.querySelector(topbarSelector),
|
const $topbar = document.querySelector(topbarSelector),
|
||||||
$dragarea = web.html`<div class="integrated_titlebar--dragarea" style="height:${dragareaHeight}px"></div>`;
|
$dragarea = web.html`<div class="integrated_titlebar--dragarea" style="height:${dragareaHeight}px"></div>`;
|
||||||
|
$topbar.style.height = `${45 + dragareaHeight}px`;
|
||||||
$topbar.prepend($dragarea);
|
$topbar.prepend($dragarea);
|
||||||
|
|
||||||
const $topbarActions = document.querySelector(topbarActionsSelector),
|
const $topbarActions = document.querySelector(topbarActionsSelector),
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = async function (api, db, __exports, __eval) {
|
module.exports = async function ({ env }, db, __exports, __eval) {
|
||||||
const electron = require('electron'),
|
const electron = require('electron'),
|
||||||
{ isMenuOpen } = require('notion-enhancer/worker.cjs'),
|
{ isMenuOpen } = require('notion-enhancer/worker.cjs'),
|
||||||
|
urlHelpers = env.notionRequire('helpers/urlHelpers'),
|
||||||
runInBackground = await db.get(['run_in_background']);
|
runInBackground = await db.get(['run_in_background']);
|
||||||
if (!runInBackground) return;
|
if (!runInBackground) return;
|
||||||
|
|
||||||
@ -34,10 +35,23 @@ module.exports = async function (api, db, __exports, __eval) {
|
|||||||
throw new Error('<fake error>: prevent window close');
|
throw new Error('<fake error>: prevent window close');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// no other windows yet + opened at startup = hide
|
||||||
|
const wasOpenedAtStartup =
|
||||||
|
process.argv.includes('--startup') ||
|
||||||
|
app.getLoginItemSettings({ args: ['--startup'] }).wasOpenedAtLogin;
|
||||||
|
if (!windows.length && wasOpenedAtStartup) {
|
||||||
|
window.once('ready-to-show', () => window.hide());
|
||||||
|
}
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
} else {
|
} else {
|
||||||
// prevents duplicate windows on dock/taskbar click
|
// prevents duplicate windows on dock/taskbar click
|
||||||
windows[0].focus();
|
windows[0].focus();
|
||||||
|
if (relativeUrl) {
|
||||||
|
// handle requests passed via the notion:// protocol
|
||||||
|
windows[0].loadURL(urlHelpers.getIndexUrl(relativeUrl));
|
||||||
|
}
|
||||||
return windows[0];
|
return windows[0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,7 @@ module.exports = async function ({ env, registry }, db, __exports, __eval) {
|
|||||||
path = require('path'),
|
path = require('path'),
|
||||||
enhancerIcon = path.resolve(`${__dirname}/../../media/colour-x16.png`),
|
enhancerIcon = path.resolve(`${__dirname}/../../media/colour-x16.png`),
|
||||||
hotkey = await db.get(['hotkey']),
|
hotkey = await db.get(['hotkey']),
|
||||||
|
openAtStartup = await db.get(['startup']),
|
||||||
runInBackground = await db.get(['run_in_background']),
|
runInBackground = await db.get(['run_in_background']),
|
||||||
menuHotkey = await (
|
menuHotkey = await (
|
||||||
await registry.db('a6621988-551d-495a-97d8-3c568bca2e9e')
|
await registry.db('a6621988-551d-495a-97d8-3c568bca2e9e')
|
||||||
@ -34,6 +35,8 @@ module.exports = async function ({ env, registry }, db, __exports, __eval) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
await electron.app.whenReady();
|
await electron.app.whenReady();
|
||||||
|
electron.app.setLoginItemSettings({ openAtLogin: openAtStartup, args: ['--startup'] });
|
||||||
|
|
||||||
tray = new electron.Tray(enhancerIcon);
|
tray = new electron.Tray(enhancerIcon);
|
||||||
tray.setToolTip('notion-enhancer');
|
tray.setToolTip('notion-enhancer');
|
||||||
tray.on('click', () => toggleWindows(false));
|
tray.on('click', () => toggleWindows(false));
|
||||||
|
@ -22,6 +22,13 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"options": [
|
"options": [
|
||||||
|
{
|
||||||
|
"type": "toggle",
|
||||||
|
"key": "startup",
|
||||||
|
"label": "open notion on startup",
|
||||||
|
"tooltip": "**if the 'run notion in the background' option is also enabled, the app will open in background on startup** (this option may require relaunching the app BEFORE restarting your system to properly take effect)",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "toggle",
|
"type": "toggle",
|
||||||
"key": "run_in_background",
|
"key": "run_in_background",
|
||||||
|
Loading…
Reference in New Issue
Block a user