mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 18:50:41 +01:00
server-esm: Fix use of __dirname
This commit is contained in:
@@ -2,7 +2,8 @@ import log from "./log.js";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
const RESOURCE_DIR = path.resolve(__dirname, "../..");
|
||||
import { fileURLToPath } from "url";
|
||||
const RESOURCE_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
|
||||
// where the "trilium" executable is
|
||||
const ELECTRON_APP_ROOT_DIR = path.resolve(RESOURCE_DIR, "../..");
|
||||
|
||||
@@ -2,12 +2,14 @@ import { Menu, Tray } from 'electron';
|
||||
import path from "path";
|
||||
import windowService from "./window.js";
|
||||
import optionService from "./options.js";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
let tray: Tray;
|
||||
// `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window
|
||||
// is minimized
|
||||
let isVisible = true;
|
||||
|
||||
|
||||
// Inspired by https://github.com/signalapp/Signal-Desktop/blob/dcb5bb672635c4b29a51adec8a5658e3834ec8fc/app/tray_icon.ts#L20
|
||||
const getIconSize = () => {
|
||||
switch (process.platform) {
|
||||
@@ -23,7 +25,7 @@ const getIconPath = () => {
|
||||
const iconSize = getIconSize();
|
||||
|
||||
return path.join(
|
||||
__dirname,
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"../..",
|
||||
"images",
|
||||
"app-icons",
|
||||
|
||||
@@ -10,6 +10,9 @@ import keyboardActionsService from "./keyboard_actions.js";
|
||||
import remoteMain from "@electron/remote/main"
|
||||
import { App, BrowserWindow, WebContents, ipcMain } from 'electron';
|
||||
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname } from "path";
|
||||
|
||||
// Prevent the window being garbage collected
|
||||
let mainWindow: BrowserWindow | null;
|
||||
let setupWindow: BrowserWindow | null;
|
||||
@@ -128,7 +131,7 @@ function configureWebContents(webContents: WebContents, spellcheckEnabled: boole
|
||||
}
|
||||
|
||||
function getIcon() {
|
||||
return path.join(__dirname, '../../images/app-icons/png/256x256' + (env.isDev() ? '-dev' : '') + '.png');
|
||||
return path.join(dirname(fileURLToPath(import.meta.url)), '../../images/app-icons/png/256x256' + (env.isDev() ? '-dev' : '') + '.png');
|
||||
}
|
||||
|
||||
async function createSetupWindow() {
|
||||
|
||||
Reference in New Issue
Block a user