Merge pull request #31 from RiV-chain/go-webview-selector

Go webview selector
This commit is contained in:
Vadym Vikulin 2022-12-21 15:06:23 +02:00 committed by GitHub
commit ea969b4792
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 90 additions and 15 deletions

View file

@ -5,7 +5,6 @@ import (
"os" "os"
"github.com/RiV-chain/RiV-mesh/src/defaults" "github.com/RiV-chain/RiV-mesh/src/defaults"
"github.com/jchv/go-webview-selector"
"github.com/docopt/docopt-go" "github.com/docopt/docopt-go"
) )
@ -37,10 +36,10 @@ func main() {
Console(false) Console(false)
} }
debug := true debug := true
w := webview.New(debug) w := New(debug)
defer w.Destroy() defer w.Destroy()
w.SetTitle("RiV-mesh") w.SetTitle("RiV-mesh")
w.SetSize(690, 920, webview.HintFixed) w.SetSize(690, 920, HintFixed)
if confui.IndexHtml == "" { if confui.IndexHtml == "" {
confui.IndexHtml = defaults.GetHttpEndpoint("http://localhost:19019") confui.IndexHtml = defaults.GetHttpEndpoint("http://localhost:19019")

View file

@ -3,5 +3,39 @@
package main package main
import (
"unsafe"
"github.com/webview/webview"
)
func Console(show bool) { func Console(show bool) {
} }
type WebView = webview.WebView
type Hint = webview.Hint
const (
// HintNone specifies that width and height are default size
HintNone Hint = iota
// HintFixed specifies that window size can not be changed by a user
HintFixed
// HintMin specifies that width and height are minimum bounds
HintMin
// HintMax specifies that width and height are maximum bounds
HintMax
)
// New creates a new webview in a new window.
func New(debug bool) WebView {
return webview.New(debug)
}
// NewWindow creates a new webview using an existing window.
func NewWindow(debug bool, window unsafe.Pointer) WebView {
return webview.NewWindow(debug, window)
}

View file

@ -5,6 +5,9 @@ package main
import ( import (
"syscall" "syscall"
"unsafe"
"github.com/jchv/go-webview2"
) )
func Console(show bool) { func Console(show bool) {
@ -22,3 +25,40 @@ func Console(show bool) {
showWin.Call(hwnd, SW_HIDE) showWin.Call(hwnd, SW_HIDE)
} }
} }
type WebView = webview2.WebView
type Hint = webview2.Hint
const (
// HintNone specifies that width and height are default size
HintNone Hint = iota
// HintFixed specifies that window size can not be changed by a user
HintFixed
// HintMin specifies that width and height are minimum bounds
HintMin
// HintMax specifies that width and height are maximum bounds
HintMax
)
// New creates a new webview in a new window.
func New(debug bool) WebView {
//return webview2.New(debug)
return webview2.NewWithOptions(webview2.WebViewOptions{
Debug: debug,
WindowOptions: webview2.WindowOptions{
IconId: 101,
Title: "RiV-mesh",
Width: 706,
Height: 960,
},
})
}
// NewWindow creates a new webview using an existing window.
func NewWindow(debug bool, window unsafe.Pointer) WebView {
return webview2.NewWindow(debug, window)
}

11
go.mod
View file

@ -21,14 +21,15 @@ require (
golang.zx2c4.com/wireguard/windows v0.4.12 golang.zx2c4.com/wireguard/windows v0.4.12
) )
require gerace.dev/zipfs v0.2.0
require ( require (
github.com/jchv/go-webview-selector v0.0.0-20220126075917-13df59bce3cf // indirect gerace.dev/zipfs v0.2.0
github.com/jchv/go-webview2 v0.0.0-20220126073738-2ea27096a5eb // indirect github.com/jchv/go-webview2 v0.0.0-20221027045535-e2a104b55541
github.com/jchv/go-winloader v0.0.0-20200815041850-dec1ee9a7fd5 // indirect
) )
require github.com/webview/webview v0.0.0-20221218140943-9db4b8c3e9af
require github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
require ( require (
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/dustin/go-humanize v1.0.0 // indirect github.com/dustin/go-humanize v1.0.0 // indirect

11
go.sum
View file

@ -47,12 +47,11 @@ github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwM
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hjson/hjson-go v3.1.0+incompatible h1:DY/9yE8ey8Zv22bY+mHV1uk2yRy0h8tKhZ77hEdi0Aw= github.com/hjson/hjson-go v3.1.0+incompatible h1:DY/9yE8ey8Zv22bY+mHV1uk2yRy0h8tKhZ77hEdi0Aw=
github.com/hjson/hjson-go v3.1.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio= github.com/hjson/hjson-go v3.1.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio=
github.com/jchv/go-webview-selector v0.0.0-20220126075917-13df59bce3cf h1:LfCNdIjo0pYj7ChAEkRZKPW/GKOzQLGqz/8CbDTxBvE= github.com/jchv/go-webview2 v0.0.0-20221027045535-e2a104b55541 h1:a3nfcpypvn/2WUzZzmZ9Kc75nPOpCrYnV45zrlGcGJM=
github.com/jchv/go-webview-selector v0.0.0-20220126075917-13df59bce3cf/go.mod h1:RfUO9QcPUZ27qVS+rq9SYhhjsVNiolWwaIQdNjqFUsQ= github.com/jchv/go-webview2 v0.0.0-20221027045535-e2a104b55541/go.mod h1:/BNVc0Sw3Wj6Sz9uSxPwhCEUhhWs92hPde75K2YV24A=
github.com/jchv/go-webview2 v0.0.0-20220126073738-2ea27096a5eb h1:oKKhiqJVbFqiPo+cj7zmY/R8AaOxgLQixUAOP/bKuRM=
github.com/jchv/go-webview2 v0.0.0-20220126073738-2ea27096a5eb/go.mod h1:/BNVc0Sw3Wj6Sz9uSxPwhCEUhhWs92hPde75K2YV24A=
github.com/jchv/go-winloader v0.0.0-20200815041850-dec1ee9a7fd5 h1:pdFFlHXY9tZXmJz+tRSm1DzYEH4ebha7cffmm607bMU=
github.com/jchv/go-winloader v0.0.0-20200815041850-dec1ee9a7fd5/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= github.com/jchv/go-winloader v0.0.0-20200815041850-dec1ee9a7fd5/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
github.com/kardianos/minwinsvc v1.0.2 h1:JmZKFJQrmTGa/WiW+vkJXKmfzdjabuEW4Tirj5lLdR0= github.com/kardianos/minwinsvc v1.0.2 h1:JmZKFJQrmTGa/WiW+vkJXKmfzdjabuEW4Tirj5lLdR0=
github.com/kardianos/minwinsvc v1.0.2/go.mod h1:LUZNYhNmxujx2tR7FbdxqYJ9XDDoCd3MQcl1o//FWl4= github.com/kardianos/minwinsvc v1.0.2/go.mod h1:LUZNYhNmxujx2tR7FbdxqYJ9XDDoCd3MQcl1o//FWl4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@ -99,6 +98,8 @@ github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYp
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f h1:p4VB7kIXpOQvVn1ZaTIVp+3vuYAXFe3OJEvjbUYJLaA= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f h1:p4VB7kIXpOQvVn1ZaTIVp+3vuYAXFe3OJEvjbUYJLaA=
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
github.com/webview/webview v0.0.0-20221218140943-9db4b8c3e9af h1:QO77Qt3ucuL5l8tFIAMXrLaDx4rYI9Nz89x+nrJwYJo=
github.com/webview/webview v0.0.0-20221218140943-9db4b8c3e9af/go.mod h1:rpXAuuHgyEJb6kXcXldlkOjU6y4x+YcASKKXJNUhh0Y=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

View file

@ -18,7 +18,7 @@ $(addprefix $(OUT_DIR)/,$(ALL_PLATFORMS)):
linux-amd64: $(addprefix linux-amd64-,$(ALL_EXE)) linux-amd64: $(addprefix linux-amd64-,$(ALL_EXE))
windows-amd64: $(addprefix windows-amd64-,$(ALL_EXE)) windows-amd64: $(addprefix windows-amd64-,$(ALL_EXE))
windows-amd64-%: BUILD_ENV=CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ #windows-amd64-%: BUILD_ENV=CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++
macos-amd64: $(addprefix macos-amd64-,$(ALL_EXE)) macos-amd64: $(addprefix macos-amd64-,$(ALL_EXE))
macos-amd64-%: BUILD_ENV=GO111MODULE=on macos-amd64-%: BUILD_ENV=GO111MODULE=on

View file

@ -338,7 +338,7 @@ func (a *AdminSocket) StartHttpServer(configFn string, nc *config.NodeConfig) {
} }
fmt.Fprint(w, string(b[:])) fmt.Fprint(w, string(b[:]))
case "POST": case "POST":
handlePost() _ = handlePost()
case "PUT": case "PUT":
if handleDelete() == nil { if handleDelete() == nil {
if handlePost() == nil { if handlePost() == nil {