Electron in vuex store
I’d like to import ipcRenderer from electron into my vuex store to call some actions before quitting the application. It works fine if I’m working in an electron environment, but if working spa it throws out a fs.existsSync error.
I found some guidance on stackoverflow about using a preload script, but looking at the official docs that talks about it being used if I have node integration off which I don’t as I need it for some other stuff.
I just wanted to check if using a pre-load script was the right thing to be doing to add electron capability to the store?
beets last edited by
@xdesai ipcRenderer definitely won’t work in SPA mode. What are you trying to accomplish here? Are you wanting to build both to Electron and SPA? As in publish a desktop app and an online app?
Yes, I’ve got a bit of an odd use case where some users might need offline capability for a while hence the electron (and I want to use Node integration for other stuff so not pwa) whereas others will be using it online only hence spa. I could probably write a separate connection that electron could call to through node bindings if I need to. As an aside, I’ve been reading up more on PWAs and service workers - can I use a service worker in electron mode? How would I go about setting that up?
beets last edited by
Also, there’s not really a need for using a service worker with electron. Again, if you’re able to explain what you want to do, we can give guidance.
@beets I’d like to still be able to show some images (potentially videos) to the offline users (content in firebase storage), as well as upload any content when back online. Some of the content they might not have navigated to specifically before, so before quitting the app I wanted to do a sync (hence doing a call to the store from electron main) to download files to filesystem (functionality not required for SPA users). I have figured out how to spin up a local express app to serve the content as static. I’ve never done anything with caching before, but was reading up a bit about service workers ability to do so for offline content, hence the question.
I’m also using the Node integration for an admin module that will only ship on the electron version.