Merge pull request #170 from electron-vite/dev

`electron/preload/index.ts` instead of `electron/preload/splash.ts`
This commit is contained in:
草鞋没号 2022-06-29 07:34:00 +08:00 committed by GitHub
commit 4672552a8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -38,7 +38,7 @@ npm create electron-vite
+ │ ├─┬ main
+ │ │ └── index.ts entry of Electron-main
+ │ └─┬ preload
+ │ └── splash.ts entry of Electron-preload
+ │ └── index.ts entry of Electron-preload
├─┬ src
│ └── main.ts entry of Electron-renderer
├── index.html

View File

@ -16,7 +16,7 @@ process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
let win: BrowserWindow | null = null
// Here, you can also use other preload
const splash = join(__dirname, '../preload/splash.js')
const preload = join(__dirname, '../preload/index.js')
// 🚧 Use ['ENV_NAME'] avoid vite:define plugin
const url = `http://${process.env['VITE_DEV_SERVER_HOST']}:${process.env['VITE_DEV_SERVER_PORT']}`
@ -24,7 +24,7 @@ async function createWindow() {
win = new BrowserWindow({
title: 'Main window',
webPreferences: {
preload: splash,
preload,
nodeIntegration: true,
contextIsolation: false,
},
@ -77,7 +77,7 @@ app.on('activate', () => {
ipcMain.handle("open-win", (event, arg) => {
const childWindow = new BrowserWindow({
webPreferences: {
preload: splash,
preload,
},
})

View File

@ -23,7 +23,7 @@ export default defineConfig({
preload: {
input: {
// You can configure multiple preload here
splash: join(__dirname, 'electron/preload/splash.ts'),
index: join(__dirname, 'electron/preload/index.ts'),
},
vite: {
build: {