Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

BrowserView with go-astilectron #320

Open
Rukenshia opened this issue May 2, 2021 · 4 comments
Open

BrowserView with go-astilectron #320

Rukenshia opened this issue May 2, 2021 · 4 comments
Assignees

Comments

@Rukenshia
Copy link

Rukenshia commented May 2, 2021

Hi there,

I wanted to try and use go-astilectron to create an application that loads another website and adds additional functionality for it - it's a website that allows downloading mods for a game.
Now, when loading the website directly in a NewWindow, I can see some JavaScript errors which seem to stem from JS files being loaded out of order (it loads fine in a <webview>). From what info I could gather, it looks like I should be using a <webview> tag or a BrowserView. <webview> is discouraged, so I tried looking up how to create a BrowserView with this package, but was unable to find anything. Is there a way of creating a BrowserView with go-astilectron or another workaround?

Cheers,

@asticode
Copy link
Owner

asticode commented May 2, 2021

Mmm I find it weird that JS files would be loaded out of order using a Window and not a BrowserView... 🤔 Could you share JS errors here?

Unfortunately right now BrowserView is not handled by this lib.

@Rukenshia
Copy link
Author

Thank you so much for your quick reply, really appreciate it!

Here's the code I used:

package main

import (
	"log"
	"os"

	"github.com/asticode/go-astikit"
	"github.com/asticode/go-astilectron"
)

func main() {
	// Initialize astilectron
	a, _ := astilectron.New(log.New(os.Stderr, "", 0), astilectron.Options{
		AppName:            "Flightsim.to desktop",
		AppIconDefaultPath: "./icon.png",
	})
	defer a.Close()

	// Start astilectron
	a.Start()

	var w, _ = a.NewWindow("https://flightsim.to", &astilectron.WindowOptions{
		Center: astikit.BoolPtr(true),
	})
	w.Create()
	w.OpenDevTools()

	// Blocking pattern
	a.Wait()
}

It throws a bunch of errors about jQuery not being available:

image

If I change the URL to google.com and navigate to the website, I can see that a jQuery asset gets loaded, but after the bundle.js file:

image

@asticode
Copy link
Owner

asticode commented May 3, 2021

OK I get it. Check out this comment.

Do you have control on the website you're loading?

@Rukenshia
Copy link
Author

Thanks for the context!

Sadly I don't control the website - I'm currently using a webview and it works fine so far, but I'm not sure if that will work long term for me without a BrowserView judging from their notes on webview. Feel free to close the issue if BrowserView support won't be possible :)

Thanks a lot for your help again!

@asticode asticode self-assigned this May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants