mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
refactor(tray): use named functions instead of arrow fn
This commit is contained in:
parent
c09ef76f87
commit
9e0d002704
@ -10,7 +10,7 @@ let tray: Tray;
|
|||||||
let isVisible = true;
|
let isVisible = true;
|
||||||
|
|
||||||
// Inspired by https://github.com/signalapp/Signal-Desktop/blob/dcb5bb672635c4b29a51adec8a5658e3834ec8fc/app/tray_icon.ts#L20
|
// Inspired by https://github.com/signalapp/Signal-Desktop/blob/dcb5bb672635c4b29a51adec8a5658e3834ec8fc/app/tray_icon.ts#L20
|
||||||
const getIconSize = () => {
|
function getIconSize() {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
return 16;
|
return 16;
|
||||||
@ -19,13 +19,15 @@ const getIconSize = () => {
|
|||||||
default:
|
default:
|
||||||
return 256;
|
return 256;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
const getIconPath = () => {
|
|
||||||
|
function getIconPath() {
|
||||||
const iconSize = getIconSize();
|
const iconSize = getIconSize();
|
||||||
|
|
||||||
return path.join(path.dirname(fileURLToPath(import.meta.url)), "../..", "images", "app-icons", "png", `${iconSize}x${iconSize}.png`);
|
return path.join(path.dirname(fileURLToPath(import.meta.url)), "../..", "images", "app-icons", "png", `${iconSize}x${iconSize}.png`);
|
||||||
};
|
}
|
||||||
const registerVisibilityListener = () => {
|
|
||||||
|
function registerVisibilityListener() {
|
||||||
const mainWindow = windowService.getMainWindow();
|
const mainWindow = windowService.getMainWindow();
|
||||||
if (!mainWindow) {
|
if (!mainWindow) {
|
||||||
return;
|
return;
|
||||||
@ -43,9 +45,9 @@ const registerVisibilityListener = () => {
|
|||||||
|
|
||||||
mainWindow.on("minimize", updateTrayMenu);
|
mainWindow.on("minimize", updateTrayMenu);
|
||||||
mainWindow.on("maximize", updateTrayMenu);
|
mainWindow.on("maximize", updateTrayMenu);
|
||||||
};
|
}
|
||||||
|
|
||||||
const updateTrayMenu = () => {
|
function updateTrayMenu() {
|
||||||
const mainWindow = windowService.getMainWindow();
|
const mainWindow = windowService.getMainWindow();
|
||||||
if (!mainWindow) {
|
if (!mainWindow) {
|
||||||
return;
|
return;
|
||||||
@ -77,8 +79,9 @@ const updateTrayMenu = () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
tray?.setContextMenu(contextMenu);
|
tray?.setContextMenu(contextMenu);
|
||||||
};
|
}
|
||||||
const changeVisibility = () => {
|
|
||||||
|
function changeVisibility() {
|
||||||
const window = windowService.getMainWindow();
|
const window = windowService.getMainWindow();
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return;
|
||||||
@ -90,7 +93,7 @@ const changeVisibility = () => {
|
|||||||
window.show();
|
window.show();
|
||||||
window.focus();
|
window.focus();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function createTray() {
|
function createTray() {
|
||||||
if (optionService.getOptionBool("disableTray")) {
|
if (optionService.getOptionBool("disableTray")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user