diff --git a/electron/main.ts b/electron/main.ts index 0454c4917..b560ea0f6 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -15,10 +15,9 @@ function createWindow(): void { mainWindow = new BrowserWindow({ icon: join(ROOT_PATH.dist, 'pwa-512x512.png'), webPreferences: { - webSecurity: false, - contextIsolation: false, - nodeIntegration: true, - allowRunningInsecureContent: true, + preload: join(ROOT_PATH.dist, 'electron/preload.js'), + contextIsolation: true, + nodeIntegration: false, }, width, height, diff --git a/electron/preload.ts b/electron/preload.ts new file mode 100644 index 000000000..e69de29bb diff --git a/vite.config.ts b/vite.config.ts index 7def5da23..3bbdf9ef0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,22 +14,32 @@ const isBuilding = process.argv.includes('build') export default defineConfig({ plugins: [ (isElectron || isBuilding) && - electron({ - entry: 'electron/main.ts', - vite: { - build: { - outDir: 'dist/electron', + electron([ + { + entry: 'electron/main.ts', + vite: { + build: { + outDir: 'dist/electron', + }, + }, + onstart: () => { + // @ts-ignore: process.electronApp exists in vite-plugin-electron but not in the types + if (process.electronApp) { + // @ts-ignore: process.electronApp.pid exists in vite-plugin-electron but not in the types + treeKillSync(process.electronApp.pid) + } + startup() }, }, - onstart: () => { - // @ts-ignore: process.electronApp exists in vite-plugin-electron but not in the types - if (process.electronApp) { - // @ts-ignore: process.electronApp.pid exists in vite-plugin-electron but not in the types - treeKillSync(process.electronApp.pid) - } - startup() + { + entry: 'electron/preload.ts', + vite: { + build: { + outDir: 'dist/electron', + }, + }, }, - }), + ]), vue(), vuetify({ autoImport: true,