Open djcas9 opened 2 years ago
You'll need to modify both go and JS projects.
Regarding the JS project, here's what you need to do:
appCmdSetAsDefaultProtocolClient and
appEventSetAsDefaultProtocolClient` herecase
statement here listening for appCmdSetAsDefaultProtocolClient
, execute app.setAsDefaultProtocolClient
with the args provided in the json
object, and return the boolean result of the function in a appEventSetAsDefaultProtocolClient
event using a success
json keyIn the go project:
Protocol string
Args []string
Success *bool
appCmdSetAsDefaultProtocolClient
and appEventSetAsDefaultProtocolClient
here(a *Astilectron) SetAsDefaultProtocolClient(protocol, path string, args []string) error
method that will do this:var e Event
if e, err = synchronousEvent(a.worker.Context(), a, a.writer, Event{Name: appCmdSetAsDefaultProtocolClient, Protocol: protocol, Path: path, Args: args}, appEventSetAsDefaultProtocolClient); err != nil {
// TODO Process error the same way this package handle errors
return
}
if !e.Success {
//return an error as well
}
Let me know if there is anything strange you would like changed, modified, etc.
One aspect I am not sure fits the model you have built (and maybe there is a more general approach). Specifically capturing open-url
in the way I did.
It feels like there should be a way to achieve the same thing from go-astilectron w/o needing to modify astilectron but I didn't see anything (or didn't look hard enough).
Doc: https://www.electronjs.org/docs/latest/api/app#appsetasdefaultprotocolclientprotocol-path-args
How could I go about adding support for something like this?