Documentation
¶
Index ¶
- Variables
- type Hint
- type WebView
- func (w *WebView) Bind(name string, f interface{}) error
- func (w *WebView) BindLog(funcName ...string) error
- func (w *WebView) Destroy()
- func (w *WebView) Eval(js string)
- func (w *WebView) EvalAsync(js string, f func(result interface{}, err error), timeout ...time.Duration) error
- func (w *WebView) EvalSync(js string, timeout ...time.Duration) (interface{}, error)
- func (w *WebView) GetBrowser() *edge.Chromium
- func (w *WebView) GetHWND() uintptr
- func (w *WebView) GoBack() *WebView
- func (w *WebView) GoForward() *WebView
- func (w *WebView) Init(js string)
- func (w *WebView) Navigate(url string)
- func (w *WebView) Refresh(forceReload ...bool) *WebView
- func (w *WebView) Reload() *WebView
- func (w *WebView) SetHtml(html string)
- func (w *WebView) SetSize(width int, height int, hints Hint)
- func (w *WebView) SetTitle(title string)
- func (w *WebView) Stop() *WebView
- type XcWebViewOption
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEvalTimeout 是执行 js 代码超时. ErrEvalTimeout = errors.New("执行超时") )
Functions ¶
This section is empty.
Types ¶
type WebView ¶
type WebView struct {
// contains filtered or unexported fields
}
func New ¶
func New(hParent int, opt XcWebViewOption) *WebView
New 创建 webview 窗口到炫彩窗口或元素, 失败返回nil.
hParent: 炫彩窗口或元素句柄.
opt: 选项.
func (*WebView) Bind ¶
Bind 绑定一个Go函数,使其以给定的名称 作为全局 JavaScript 函数出现。内部使用 webview_init()。必须在UI线程执行.
f 必须是一个函数:
- 函数参数没什么限制
- 函数返回值可以是一个值或一个error
- 函数返回值可以是一个值和一个error
func (*WebView) BindLog ¶
BindLog 绑定一个日志输出函数, 参数不限个数, 在js代码中调用, 会在go控制台中输出.
funcName: 自定义函数名, 为空默认为glog.
func (*WebView) EvalAsync ¶
func (w *WebView) EvalAsync(js string, f func(result interface{}, err error), timeout ...time.Duration) error
EvalAsync 执行 js 代码, 可在回调函数中异步获取结果. 必须在UI线程执行.
js: js 代码.
f: 可在回调函数中获取js代码执行结果以及错误, 为 nil 时, 等同于执行了 Eval. 注意这个回调函数是在协程中执行的, 不是在UI线程.
timeout: 超时时间, 为空默认10秒.
func (*WebView) EvalSync ¶
EvalSync 执行 js 代码, 同步取回返回值. 必须在UI线程执行.
js: js 代码.
timeout: 超时时间, 为空默认10秒.
func (*WebView) GetBrowser ¶
func (*WebView) Init ¶
Init 在新页面初始化时注入 JavaScript 代码。每次 webview 将打开一个新页面 - 此初始化代码将被执行。保证代码在 window.onload 之前执行。
func (*WebView) Navigate ¶
Navigate 导航 webview 到给定的 URL。URL 可能是数据 URI,即 "data:text/text,<html>...</html>"。通常不进行适当的 url 编码也是可以的, webview 会为你重新编码。
func (*WebView) Refresh ¶
Refresh 网页_刷新.
forceReload: 是否强制刷新, 默认为false. 为 true 时,浏览器会强制重新加载页面,忽略缓存。这意味着无论页面是否已经在本地缓存中,都会从服务器重新获取资源。
type XcWebViewOption ¶
type XcWebViewOption struct {
// WebView2 宿主窗口标题
Title string
// WebView2 宿主窗口类名
ClassName string
// DataPath 指定 WebView2 运行时用于浏览器实例的数据路径。
DataPath string
IconId uint
// 左边
Left int32
// 顶边
Top int32
// 宽度
Width int32
// 高度
Height int32
// 填充父, 如果为true, 则 webView 会填满父窗口或元素, 固定坐标和尺寸会失效.
FillParent bool
// Debug 是否可开启开发者工具.
Debug bool
// AutoFocus 将在窗口获得焦点时尝试保持 webView 的焦点。
AutoFocus bool
}
XcWebViewOption 是给 xcgui 定制的 WebViewOption.
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
CalcMD5
command
计算文件MD5.
|
计算文件MD5. |
|
CreateByLayoutEle
command
在布局元素中创建 WebView
|
在布局元素中创建 WebView |
|
CreateByWindow
command
在窗口中创建 WebView
|
在窗口中创建 WebView |
|
internal
|
|
|
pkg
|
|

