SimulatedGREG / electron-vue

An Electron & Vue.js quick start boilerplate with vue-cli scaffolding, common Vue plugins, electron-packager/electron-builder, unit/e2e testing, vue-devtools, and webpack.
https://simulatedgreg.gitbooks.io/electron-vue/content/
MIT License
15.47k stars 1.55k forks source link

[resolved] webContents: did-finish-load #1021

Closed lurein closed 4 years ago

lurein commented 4 years ago
Describe the issue / bug.

I need to initialize a push notification module on the webcontents did-finish-load event, but I understand that under this framework that doesn't fire at any point. How would I go about implementing this otherwise? #

lurein commented 4 years ago

Update: I figured out a solution on this using ipcMain / Renderer.

In src/main/index.js import { app, BrowserWindow, ipcMain} from 'electron' and then

ipcMain.on('readyPush', () =>{ console.log('initialize push notifs here') })

in src/renderer/FirstPage.vue mounted () { this.$electron.ipcRenderer.send('readyPush') },

this should work, since with our vue framework the window has no did-finish-load event, the mounted hook should work in its place. A note that confused me for a while - console.log statements in the main/index.js file don't appear in the devtools - they show up in the terminal window