Closed rkrasnan closed 1 year ago
That could be one way to do it. Are dialogs working properly?
Yes I am able to access the dialog inside of my vue app and it works properly.
I also have the EnabledRemoteModule flagged as true from here https://github.com/asticode/go-astilectron/issues/314#issuecomment-1186537805
Adding const {dialog} = require('electron').remote;
in my vue app wouldn't compile since electron isn't part of that project.
But index.js was created by the bundler, so this code change will be overwritten every time I build. Should I open a PR for this change or am I way off base?
I was able to achieve this without needing to edit the index.js file using the custom.script
in main.go, in the astilectron.WindowOptions
...
Options: &astilectron.WindowOptions{
...
WebPreferences: &astilectron.WebPreferences{EnableRemoteModule: astikit.BoolPtr(true)},
Custom: &astilectron.WindowCustomOptions{Script: `const {dialog} = require("electron").remote; astilectron.dialog = dialog;`},
},
...
I was able to achieve this without needing to edit the index.js file using the custom.script
I love this idea!
Did you really need the astilectron.dialog = dialog;
or could you remove it and call dialog.[...]
in your javascript instead?
You are right, I didn't need that part and now I have access to dialog in my vue components.
eslint doesn't like it but the vue app compiles and the dialogs work properly.
Thanks a lot for sharing! ❤️
Thank you for the guidance!
I have edited my vendor/astilectron/index.js code to expose the dialog via the astilectron object.
Starting on line 536
This made it so I could extend vue/src/plugins/astor.js and further expose the dialog to the rest of my app.
Is this a good way to get access to the dialog object?