From 8a67ac6954b39453051406231e54eb111e0e5307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Wed, 14 Sep 2022 08:22:25 +0800 Subject: [PATCH] feat: `process.env.DIST`, `process.env.PUBLIC` --- electron/main/index.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index a368070..6463dce 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -18,23 +18,19 @@ if (!app.requestSingleInstanceLock()) { // Read more on https://www.electronjs.org/docs/latest/tutorial/security // process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true' -export const ROOT_PATH = { - // /dist - dist: join(__dirname, '../..'), - // /dist or /public - public: join(__dirname, app.isPackaged ? '../..' : '../../../public'), -} +process.env.DIST = join(__dirname, '../..') +process.env.PUBLIC = app.isPackaged ? process.env.DIST : join(process.env.DIST, '../public') let win: BrowserWindow | null = null // Here, you can also use other preload const preload = join(__dirname, '../preload/index.js') const url = process.env.VITE_DEV_SERVER_URL as string -const indexHtml = join(ROOT_PATH.dist, 'index.html') +const indexHtml = join(process.env.DIST, 'index.html') async function createWindow() { win = new BrowserWindow({ title: 'Main window', - icon: join(ROOT_PATH.public, 'favicon.ico'), + icon: join(process.env.PUBLIC, 'favicon.ico'), webPreferences: { preload, // Warning: Enable nodeIntegration and disable contextIsolation is not secure in production