From 72a74b89d80ef1312db376334a70fd14d53ba45f 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: Fri, 4 Aug 2023 11:27:49 +0800 Subject: [PATCH] fix: Rename PUBLIC environment variable to avoid problems with child_process --- electron/electron-env.d.ts | 2 +- electron/main/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts index d02e86c..b4c4211 100644 --- a/electron/electron-env.d.ts +++ b/electron/electron-env.d.ts @@ -6,6 +6,6 @@ declare namespace NodeJS { DIST_ELECTRON: string DIST: string /** /dist/ or /public/ */ - PUBLIC: string + VITE_PUBLIC: string } } diff --git a/electron/main/index.ts b/electron/main/index.ts index a1bed6c..ccee8e4 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -14,7 +14,7 @@ import { join } from 'node:path' // process.env.DIST_ELECTRON = join(__dirname, '..') process.env.DIST = join(process.env.DIST_ELECTRON, '../dist') -process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL +process.env.VITE_PUBLIC = process.env.VITE_DEV_SERVER_URL ? join(process.env.DIST_ELECTRON, '../public') : process.env.DIST @@ -43,7 +43,7 @@ const indexHtml = join(process.env.DIST, 'index.html') async function createWindow() { win = new BrowserWindow({ title: 'Main window', - icon: join(process.env.PUBLIC, 'favicon.ico'), + icon: join(process.env.VITE_PUBLIC, 'favicon.ico'), webPreferences: { preload, // Warning: Enable nodeIntegration and disable contextIsolation is not secure in production