feat: process.env.DIST, process.env.PUBLIC

This commit is contained in:
草鞋没号 2022-09-14 08:22:25 +08:00
parent 4b46601879
commit 8a67ac6954

View File

@ -18,23 +18,19 @@ if (!app.requestSingleInstanceLock()) {
// Read more on https://www.electronjs.org/docs/latest/tutorial/security // Read more on https://www.electronjs.org/docs/latest/tutorial/security
// process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true' // process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
export const ROOT_PATH = { process.env.DIST = join(__dirname, '../..')
// /dist process.env.PUBLIC = app.isPackaged ? process.env.DIST : join(process.env.DIST, '../public')
dist: join(__dirname, '../..'),
// /dist or /public
public: join(__dirname, app.isPackaged ? '../..' : '../../../public'),
}
let win: BrowserWindow | null = null let win: BrowserWindow | null = null
// Here, you can also use other preload // Here, you can also use other preload
const preload = join(__dirname, '../preload/index.js') const preload = join(__dirname, '../preload/index.js')
const url = process.env.VITE_DEV_SERVER_URL as string 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() { async function createWindow() {
win = new BrowserWindow({ win = new BrowserWindow({
title: 'Main window', title: 'Main window',
icon: join(ROOT_PATH.public, 'favicon.ico'), icon: join(process.env.PUBLIC, 'favicon.ico'),
webPreferences: { webPreferences: {
preload, preload,
// Warning: Enable nodeIntegration and disable contextIsolation is not secure in production // Warning: Enable nodeIntegration and disable contextIsolation is not secure in production