This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "app_name": "Astilectron demo", | |
| "icon_path_darwin": "resources/icon.icns", | |
| "icon_path_linux": "resources/icon.png", | |
| "icon_path_windows": "resources/icon.ico", | |
| "output_path": "output" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func main() { | |
| bootstrap.Run(bootstrap.Options{ | |
| Asset: Asset, | |
| RestoreAssets: RestoreAssets, | |
| }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let index = { | |
| about: function(html) { | |
| let c = document.createElement("div"); | |
| c.innerHTML = html; | |
| asticode.modaler.setContent(c); | |
| asticode.modaler.show(); | |
| }, | |
| init: function() { | |
| // Wait for astilectron to be ready | |
| document.addEventListener('astilectron-ready', function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func main() { | |
| // Create logger | |
| l := log.New(log.Writer(), log.Prefix(), log.Flags()) | |
| // Run bootstrap | |
| bootstrap.Run(bootstrap.Options{ | |
| MenuOptions: []*astilectron.MenuItemOptions{{ | |
| Label: astilectron.PtrStr("File"), | |
| SubMenu: []*astilectron.MenuItemOptions{ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This will wait for the astilectron namespace to be ready | |
| document.addEventListener('astilectron-ready', function() { | |
| // This will listen to messages sent by GO | |
| astilectron.onMessage(function(message) { | |
| // Process message | |
| if (message.name === "event.name") { | |
| return {payload: message.message + " world"}; | |
| } | |
| }); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "io/ioutil" | |
| "os" | |
| "os/user" | |
| "path/filepath" | |
| "sort" | |
| "strconv" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let index = { | |
| addFolder(name, path) { | |
| let div = document.createElement("div"); | |
| div.className = "dir"; | |
| div.onclick = function() { index.explore(path) }; | |
| div.innerHTML = `<i class="fa fa-folder"></i><span>` + name + `</span>`; | |
| document.getElementById("dirs").appendChild(div) | |
| }, | |
| init: function() { | |
| // Wait for astilectron to be ready |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This will send a message and execute a callback | |
| // Callbacks are optional | |
| bootstrap.SendMessage(w, "event.name", "hello", func(m *bootstrap.MessageIn) { | |
| // Unmarshal payload | |
| var s string | |
| json.Unmarshal(m.Payload, &s) | |
| // Process message | |
| log.Infof("received %s", s) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func main() { | |
| bootstrap.Run(bootstrap.Options{ | |
| MessageHandler: handleMessages, | |
| }) | |
| } | |
| // handleMessages handles messages | |
| func handleMessages(_ *astilectron.Window, m bootstrap.MessageIn) (payload interface{}, err error) { | |
| switch m.Name { | |
| case "event.name": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This will wait for the astilectron namespace to be ready | |
| document.addEventListener('astilectron-ready', function() { | |
| // This will send a message to GO | |
| astilectron.sendMessage({name: "event.name", payload: "hello"}, function(message) { | |
| console.log("received " + message.payload) | |
| }); | |
| }) |