Closed mzky closed 2 years ago
Adding only the bundler.json
file is not sufficient to use the bundler
.
If you checkout the demo, you can see that everything is wrapped in the bootstrap.Run
function which is mandatory if you want to use the bundler
.
thank you for response .
Yes, I saw the bootstrap.Run(bootstrap.Options{
thing, but I want to go directly to the URL.
How does bootstrap.Run
access URL.
If I write it this way, the program won't re-download electron
, but it will get an error.
package main
import (
bootstrap "github.com/asticode/go-astilectron-bootstrap"
"log"
"os"
"github.com/asticode/go-astikit"
"github.com/asticode/go-astilectron"
)
func main() {
bootstrap.Run(bootstrap.Options{
Asset: Asset,
AssetDir: AssetDir,
RestoreAssets: RestoreAssets,
})
// Initialize astilectron
a, _ := astilectron.New(log.New(os.Stderr, "", 0), astilectron.Options{
AppName: "demo",
AppIconDefaultPath: "./icon.png",
})
defer a.Close()
a.Start()
var w, _ = a.NewWindow("https://www.google.com", &astilectron.WindowOptions{
BackgroundColor: astikit.StrPtr("#333"),
Center: astikit.BoolPtr(true),
Height: astikit.IntPtr(700),
Width: astikit.IntPtr(700),
})
w.Create()
a.Wait()
}
Not root user:
astikit: starting worker...
Starting...
Provisioning...
Listening...
Executing...
Starting cmd /home/admin/vendor/electron-linux-amd64/electron /home/admin/vendor/astilectron/main.js 127.0.0.1:42219 false
Stderr says: [1286:0124/170639.869465:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /home/admin/vendor/electron-linux-amd64/chrome-sandbox is owned by root and has mode 4755.
'/home/admin/vendor/electron-linux-amd64/electron' exited with code: -1
App has crashed
First off, in the code you share, the following part is useless :
// Initialize astilectron
a, _ := astilectron.New(log.New(os.Stderr, "", 0), astilectron.Options{
AppName: "demo",
AppIconDefaultPath: "./icon.png",
})
defer a.Close()
a.Start()
var w, _ = a.NewWindow("https://www.google.com", &astilectron.WindowOptions{
BackgroundColor: astikit.StrPtr("#333"),
Center: astikit.BoolPtr(true),
Height: astikit.IntPtr(700),
Width: astikit.IntPtr(700),
})
w.Create()
a.Wait()
bootstrap.Run
will take care of doing that part
You can provide your URL directly in the bootstrap.Options
. Checkout here.
It is running normally. Thank you again.
Please excuse my poor English. I have a very small demo. After bundler, the file is in 80M, so it can be seen that the "electron" file is included, but I am still requesting to download the "electron" file when I run it. May I ask if there is anything else I need to configure?
bundler.js
demo.go