From b2a073cc8d4fbd510a7edab5c132a0c6a848db52 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: Sat, 17 Sep 2022 08:23:23 +0800 Subject: [PATCH] feat: hoist `process.env` --- electron/main/index.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index 46a0642..4e13919 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -1,3 +1,18 @@ +// The built directory structure +// +// ├─┬ dist +// │ ├─┬ electron +// │ │ ├─┬ main +// │ │ │ └── index.js +// │ │ └─┬ preload +// │ │ └── index.js +// │ ├── index.html +// │ ├── ...other-static-files-from-public +// │ +process.env.DIST = join(__dirname, '../..') +process.env.PUBLIC = app.isPackaged ? process.env.DIST : join(process.env.DIST, '../public') +process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true' + import { app, BrowserWindow, shell, ipcMain } from 'electron' import { release } from 'os' import { join } from 'path' @@ -13,10 +28,6 @@ if (!app.requestSingleInstanceLock()) { process.exit(0) } -process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true' -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')