Categorygithub.com/itgowo/gowebview
modulepackage
1.0.3
Repository: https://github.com/itgowo/gowebview.git
Documentation: pkg.go.dev

# README

gowebview

修改createWindow , 增加handle windows.Handle参数,可以将webview直接放到指定window上

GoDoc Go Report Card

A small WebView without CGO, based on webview/webview. The main goal was to avoid CGO and make it possible to embed the DLLs. Instead of relying directly on CGO as webview/webview, the inkeliz/gowebview uses golang.org/x/sys/windows, for Windows.

Why use inkeliz/gowebview?

  • If you like to avoid CGO on Windows.
  • If you like to have a single .exe.

Why use webview/webview?

  • If you need support for Darwin/Linux.
  • If you need binds from Javascript to Golang.
  • If you like to use a more battle-tested and stable library.

Getting started

Import the package and start using it:

package main

import "github.com/inkeliz/gowebview"

func main() {
	w, err := gowebview.New(&gowebview.Config{URL: "https://google.com", WindowConfig: &gowebview.WindowConfig{Title: "Hello World"}})
	if err != nil {
		panic(err)
	}

	defer w.Destroy()
	w.Run()
}

It will open the https://google.com webpage, without any additional setup.

TODO

  1. Add support to programmatically allow "locahost connections".

    Currently you must run CheckNetIsolation.exe LoopbackExempt -a -n="Microsoft.Win32WebViewHost_cw5n1h2txyewy" externally.

    DONE. It's now implemented for Windows, if you use Config.TransportConfig{IgnoreNetworkIsolation: true}. You don't need to execute the sofware as admin, it'll be request only when needed.

  2. Improve support for Android (currently it needs Gio)

    Currently it's supported, but needs Gio to works.

  3. Remove dependency of webview.dll by calling WebView2Loader.dll directly.

    Currently, it needs to extract both .dll.

  4. Improve security by restricting where look for DLL.

    Currently gowebview adds a new filepath on %PATH%)

  5. Improve error returns.

    Currently it returns errors directly from os, windows and ioutil libraries.

License

Code is distributed under MIT license, feel free to use it in your proprietary projects as well.

Credits

It's highly based on webview/webview and webview/webview_csharp. The idea of avoid CGO was inspired by Ebiten.

# Functions

New calls NewWindow to create a new window and a new webview instance.
No description provided by the author

# Constants

HintFixed prevents the window size to be changed by a user.
HintMax set the maximum bounds.
HintMin set the minimum bounds.
HintNone set the current and default width and height.
VisibilityDefault will open the window at their default WindowMode.
VisibilityMaximized will open the window as maximized Windowless systems (like Android) will open as fullscreen.
VisibilityMinimized will open the window as minimized Windowless systems (like Android) will hides the webview (return the previous view).

# Structs

Config are used to set the initial and default values to the WebView.
HTTPProxy are used to configure the Proxy.
Point are used to configure the size or coordinates.
WindowConfig describes topics related to the network traffic.
WindowConfig describes topics related to the Window/View.

# Interfaces

WebView is the interface implemented by each webview.

# Type aliases

Hint are used to configure window sizing and resizing.
Visibility are used to configure if the window mode (maximized or minimized).