blink

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 34 Imported by: 8

README

基于免费版的 miniblink 的 GO 封装,内嵌 miniblink 的 DLL,并根据构建环境自动选择 x86/x64 DLL

特点

  1. 纯 GO 实现,无须写 C 代码
  2. 封装了大部分 miniblink 的 API,面向对象,方便使用。
  3. JS 交互(IPC通讯、事件绑定、调用JS函数),具体使用方式,请参考示例
  4. 本地目录、BIN资源的加载
  5. 内嵌 miniblink 的 DLL,并根据构建环境自动选择 x86/x64 DLL
func (mb *Blink) CallFunc(name string, args ...uintptr) (r1 uintptr, r2 uintptr, err error)

开发环境

  • GO 1.20

打包

打包标签:
  • release 打包程序,不包含调试信息,在 release 模式下,额外加 debug 标签,可以打开调试信息
  • slim 不内嵌miniblink的dll,需要手动放入程序根目录或系统默认路径
示例
# 默认打包
go build \
  -tags 'release' \
  -ldflags '-w -s -H=windowsgui' \
  -o miniBlink.exe \
  ./samples/demo-baidu

# 打包32位程序
GOARCH=386 go build \
  -tags 'release' \
  -ldflags '-w -s -H=windowsgui' \
  -o miniBlink.exe \
  ./samples/demo-baidu

添加程序版本信息、图标。。。 请查看 demo-baidumain.go 文件。并参阅 josephspurrier/goversioninfo

Documentation

Index

Constants

View Source
const (
	JS_MB               = "__mb"
	JS_IPC              = "ipc"
	JS_JS2GO            = "__js2go"
	JS_GO2JS            = "__go2js"
	JS_REGISTER_HANDLER = "__register_handler"
)
View Source
const (
	WM_USER       = win.WM_USER
	WM_TRAYNOTIFY = WM_USER + 1

	ID_TRAY             = WM_USER + 100
	ID_TRAYMENU_RESTORE = WM_USER + 101
	ID_TRAYMENU_EXIT    = WM_USER + 102
)
View Source
const ARCH_BIT = 32 << (^uint(0) >> 63)

Variables

This section is empty.

Functions

func AssertType

func AssertType[T interface{}](ptr uintptr) *T

func BoolToPtr

func BoolToPtr(b bool) uintptr

func CallbackToPtr

func CallbackToPtr(callback interface{}) uintptr

callback = func(args ...uintptr) uintptr

func CopyBytes

func CopyBytes(src uintptr, n int) []byte

func CopyString

func CopyString(src uintptr, n int) string

func Float32FromBytes

func Float32FromBytes(src []byte, startIndex int, isLittleEndian bool) (float32, error)

func Float32ToBytes

func Float32ToBytes(value float32) []byte

func Float64FromBytes

func Float64FromBytes(src []byte, startIndex int, isLittleEndian bool) (float64, error)

func Float64ToBytes

func Float64ToBytes(value float64) []byte

func HIWORD

func HIWORD(dwValue uint32) uint16

func Int16FromBytes

func Int16FromBytes(src []byte, startIndex int, isLittleEndian bool) (int16, error)

func Int16ToBytes

func Int16ToBytes(value int16) []byte

func Int32FromBytes

func Int32FromBytes(src []byte, startIndex int, isLittleEndian bool) (int32, error)

func Int32ToBytes

func Int32ToBytes(value int32) []byte

func Int64FromBytes

func Int64FromBytes(src []byte, startIndex int, isLittleEndian bool) (int64, error)

func Int64ToBytes

func Int64ToBytes(value int64) []byte

func IntFromBytes

func IntFromBytes(src []byte, startIndex int, isLittleEndian bool) (int, error)

func IntToBytes

func IntToBytes(value int) []byte

func LOWORD

func LOWORD(dwValue uint32) uint16

func PtrToBool

func PtrToBool(p uintptr) bool

func PtrToString

func PtrToString(p uintptr) string

func PtrWCharToString

func PtrWCharToString(p uintptr) string

func StringToPtr

func StringToPtr(s string) uintptr

func StringToU16Arr

func StringToU16Arr(s string) []uint16

func StringToWCharPtr

func StringToWCharPtr(s string) uintptr

func StringToWcharU16Ptr

func StringToWcharU16Ptr(s string) *uint16

func Uint16FromBytes

func Uint16FromBytes(src []byte, startIndex int, isLittleEndian bool) (uint16, error)

func Uint16ToBytes

func Uint16ToBytes(value uint16) []byte

func Uint32FromBytes

func Uint32FromBytes(src []byte, startIndex int, isLittleEndian bool) (uint32, error)

func Uint32ToBytes

func Uint32ToBytes(value uint32) []byte

func Uint64FromBytes

func Uint64FromBytes(src []byte, startIndex int, isLittleEndian bool) (uint64, error)

func Uint64ToBytes

func Uint64ToBytes(value uint64) []byte

func UintFromBytes

func UintFromBytes(src []byte, startIndex int, isLittleEndian bool) (uint, error)

func UintToBytes

func UintToBytes(value uint) []byte

func WithCookieFile

func WithCookieFile(path string) func(*Config)

func WithDllFile

func WithDllFile(dllFile string) func(*Config)

func WithDownloader

func WithDownloader(downloader *dl.Downloader) func(*Config)

func WithStoragePath

func WithStoragePath(path string) func(*Config)

func WithTempPath

func WithTempPath(path string) func(*Config)

Types

type AnyPtr

type AnyPtr = uintptr

alias

type BOOL

type BOOL int32
const FALSE BOOL = 0
const TRUE BOOL = 1

type BindFunctionCallback

type BindFunctionCallback func(es JsExecState)
type Blink struct {
	*Config
	IPC *IPC

	Resource *resource.Resource
	// contains filtered or unexported fields
}

func NewApp

func NewApp(setups ...func(*Config)) *Blink

func (*Blink) AddBootScript

func (mb *Blink) AddBootScript(script string)

func (*Blink) AddJob

func (mb *Blink) AddJob(job func()) chan bool

将单个任务塞入队列,仅执行一次

func (*Blink) AddLoop

func (mb *Blink) AddLoop(job ...func()) *Blink

增加任务到循环队列,每次循环都会执行

func (*Blink) CallFunc

func (mb *Blink) CallFunc(funcName string, args ...uintptr) (r1 uintptr, r2 uintptr, err error)

func (*Blink) CallFuncAsync

func (mb *Blink) CallFuncAsync(funcName string, args ...uintptr) *CallFuncJob

func (*Blink) CallFuncAsyncFirst

func (mb *Blink) CallFuncAsyncFirst(funcName string, args ...uintptr) *CallFuncJob

func (*Blink) CallFuncFirst

func (mb *Blink) CallFuncFirst(funcName string, args ...uintptr) (r1 uintptr, r2 uintptr, err error)

func (*Blink) CloseAll

func (mb *Blink) CloseAll()

func (*Blink) CreateWebWindowControl

func (mb *Blink) CreateWebWindowControl(parent *View, withConfig ...WithWebWindowConfig) *View

嵌入在父窗口里的子窗口

func (*Blink) CreateWebWindowPopup

func (mb *Blink) CreateWebWindowPopup(withConfig ...WithWebWindowConfig) *View

普通窗口

func (*Blink) CreateWebWindowTransparent

func (mb *Blink) CreateWebWindowTransparent(withConfig ...WithWebWindowConfig) *View

透明窗口

func (*Blink) Download

func (mb *Blink) Download(url string, withOption ...func(*downloader.Config)) (targetFile string, err error)

alias, 缩短代码

func (*Blink) Exit

func (mb *Blink) Exit()

func (*Blink) Free

func (mb *Blink) Free()

func (*Blink) GetCookies

func (mb *Blink) GetCookies() ([]*http.Cookie, error)

func (*Blink) GetFirstView

func (mb *Blink) GetFirstView() (view *View)

func (*Blink) GetString

func (mb *Blink) GetString(str WkeString) string

func (*Blink) GetViewByHandle

func (mb *Blink) GetViewByHandle(viewHwnd WkeHandle) (view *View, exist bool)

func (*Blink) GetViewByJsExecState

func (mb *Blink) GetViewByJsExecState(es JsExecState) (view *View, exist bool)

func (*Blink) GetViews

func (mb *Blink) GetViews() []*View

func (*Blink) GetWindowByHandle

func (mb *Blink) GetWindowByHandle(windowHwnd WkeHandle) (window *Window, exist bool)

func (*Blink) KeepRunning

func (mb *Blink) KeepRunning()

func (*Blink) LoopWinMessage

func (mb *Blink) LoopWinMessage()

func (*Blink) NetGetMIMEType

func (mb *Blink) NetGetMIMEType(job WkeNetJob, mime string) string

获取response的mime

func (*Blink) NetHookRequest

func (mb *Blink) NetHookRequest(job WkeNetJob)

func (*Blink) NetSetData

func (mb *Blink) NetSetData(job WkeNetJob, buf []byte)

调用此函数后,网络层收到数据会存储在一buf内,接收数据完成后响应OnLoadUrlEnd事件.#此调用严重影响性能,慎用。 此函数和wkeNetSetData的区别是,wkeNetHookRequest会在接受到真正网络数据后再调用回调,并允许回调修改网络数据。 而wkeNetSetData是在网络数据还没发送的时候修改。

func (*Blink) NetSetMIMEType

func (mb *Blink) NetSetMIMEType(job WkeNetJob, mimeType string)

设置response的mime

func (*Blink) Version

func (mb *Blink) Version() int

func (*Blink) VersionString

func (mb *Blink) VersionString() string

type BlinkJob

type BlinkJob struct {
	// contains filtered or unexported fields
}

type CallFuncJob

type CallFuncJob struct {
	// contains filtered or unexported fields
}

func (*CallFuncJob) Wait

func (cj *CallFuncJob) Wait() (r1 uintptr, r2 uintptr, err error)

type CallFuncResult

type CallFuncResult struct {
	R1  uintptr
	R2  uintptr
	Err error
}

type Callback

type Callback interface{}

type Char

type Char byte

char

func StringToChar

func StringToChar(s string) []Char

type Config

type Config struct {

	// 默认下载器
	Downloader *dl.Downloader
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(setups ...func(*Config)) (*Config, error)

func (*Config) GetCookieFileABS

func (conf *Config) GetCookieFileABS() string

func (*Config) GetDllFile

func (conf *Config) GetDllFile() string

func (*Config) GetDllFileABS

func (conf *Config) GetDllFileABS() string

func (*Config) GetStoragePath

func (conf *Config) GetStoragePath() string

func (*Config) GetTempPath

func (conf *Config) GetTempPath() string

type Double

type Double float64

double

type Float

type Float float32

float

type IPC

type IPC struct {
	// contains filtered or unexported fields
}

func (*IPC) CallJsFunc

func (ipc *IPC) CallJsFunc(view *View, funcName string, args ...interface{}) async.InProgress[interface{}]

func (*IPC) Handle

func (ipc *IPC) Handle(channel string, handler Callback)

GO 注册 Handler

handler 必须为函数,参数任意,返回值最多为2个

  • 1个返回值:会自动判断返回值是否为 error
  • 2个返回值:第一个为 结果,第二个为 error

func (*IPC) HasChannel

func (ipc *IPC) HasChannel(channel string) (exist bool)

func (*IPC) Invoke

func (ipc *IPC) Invoke(channel string, args ...interface{}) (interface{}, error)

GO 调用handler

一、GO 调用 GO handler,直接调用并返回

二、GO 调用 JS handler, 和 GO 调用 GO 流程一样,唯一区别是在 `invokeJS` 里调用 `ipc.Invoke` 执行的 `handler` 是转化后的 `JS handler`

func (*IPC) Sent

func (ipc *IPC) Sent(channel string, args ...interface{}) error

type IPCMessage

type IPCMessage struct {
	ID      string        `json:"id"`      // 消息 ID
	ReplyId string        `json:"replyId"` // 回复ID
	Channel string        `json:"channel"` // 通道
	Args    []interface{} `json:"args"`    // 参数
	Result  interface{}   `json:"result"`  // 返回值,当有回复ID时,此字段有效
	Error   string        `json:"error"`   // 是否错误,当有回复ID时,此字段有效
}

type Int

type Int int32

int

type JS

type JS struct {
	// contains filtered or unexported fields
}

func (*JS) Arg

func (js *JS) Arg(es JsExecState, argIdx uint32) JsValue

获取第argIdx对应的参数的jsValue值。

func (*JS) ArgCount

func (js *JS) ArgCount(es JsExecState) uint32

func (*JS) ArgType

func (js *JS) ArgType(es JsExecState, argIdx uint32) JsType

判断第argIdx个参数的参数类型。argIdx从是个0开始计数的值。如果超出jsArgCount返回的值,将发生崩溃

func (*JS) Boolean

func (js *JS) Boolean(value bool) JsValue

func (*JS) Call

func (js *JS) Call(es JsExecState, fn, thisValue JsValue, args []JsValue) JsValue

func (*JS) Double

func (js *JS) Double(value float64) JsValue

func (*JS) EmptyArray

func (js *JS) EmptyArray(es JsExecState) JsValue

func (*JS) EmptyObject

func (js *JS) EmptyObject(es JsExecState) JsValue

func (*JS) Eval

func (js *JS) Eval(es JsExecState, str string) JsValue

str的代码会在mb内部自动被包裹在一个function(){}中。所以使用的变量会被隔离 注意:要获取返回值,请写return。

func (*JS) Get

func (js *JS) Get(es JsExecState, object JsValue, prop string) JsValue

如果object是个js的object,则获取prop指定的属性。如果object不是js object类型,则返回 nil

func (*JS) GetAt

func (js *JS) GetAt(es JsExecState, object JsValue, index uint32) JsValue

设置js arrary的第index个成员的值,object必须是js array才有用,否则会返回nil

func (*JS) GetGlobal

func (js *JS) GetGlobal(es JsExecState, prop string) JsValue

获取window上的属性

func (*JS) GetKeys

func (js *JS) GetKeys(es JsExecState, object JsValue) []string

获取object有哪些key

func (*JS) GetLength

func (js *JS) GetLength(es JsExecState, object JsValue) int

获取js arrary的长度,object必须是js array才有用。

func (*JS) GetWebView

func (js *JS) GetWebView(es JsExecState) WkeHandle

func (*JS) GlobalExec

func (js *JS) GlobalExec(viewHandle WkeHandle) (es JsExecState)

获取页面主frame的jsExecState

func (*JS) Int

func (js *JS) Int(value int32) JsValue

func (*JS) Set

func (js *JS) Set(es JsExecState, object JsValue, prop string, value JsValue)

设置object的属性

func (*JS) SetAt

func (js *JS) SetAt(es JsExecState, object JsValue, index uint32, value JsValue)

设置js arrary的第index个成员的值,object必须是js array才有用。

func (*JS) SetGlobal

func (js *JS) SetGlobal(es JsExecState, prop string, value JsValue)

设置window上的属性

func (*JS) SetLength

func (js *JS) SetLength(es JsExecState, object JsValue, length uint32)

func (*JS) String

func (js *JS) String(es JsExecState, value string) JsValue

func (*JS) ToBoolean

func (js *JS) ToBoolean(es JsExecState, value JsValue) bool

func (*JS) ToDouble

func (js *JS) ToDouble(es JsExecState, value JsValue) float64

func (*JS) ToGoValue

func (js *JS) ToGoValue(es JsExecState, value JsValue) interface{}

func (*JS) ToJsValue

func (js *JS) ToJsValue(es JsExecState, value interface{}) JsValue

func (*JS) ToString

func (js *JS) ToString(es JsExecState, value JsValue) string

func (*JS) ToTempString

func (js *JS) ToTempString(es JsExecState, value JsValue) string

func (*JS) TypeOf

func (js *JS) TypeOf(val JsValue) JsType

func (*JS) Undefined

func (js *JS) Undefined() JsValue

type JsArg

type JsArg interface {
	int |
		string |
		bool
}

type JsData

type JsData struct {
	Name [100]byte
	PropertyGet,
	PropertySet,
	Finalize,
	CallAsFunction uintptr
}

type JsExecState

type JsExecState uintptr

type JsKeys

type JsKeys struct {
	Length uint32
	First  uintptr
}

type JsType

type JsType uint32
const (
	JsType_NUMBER JsType = iota
	JsType_STRING
	JsType_BOOLEAN
	JsType_OBJECT
	JsType_FUNCTION
	JsType_UNDEFINED
	JsType_ARRAY
	JsType_NULL
)

type JsValue

type JsValue uintptr

type KnownCType

type KnownCType interface {
	// char
	Char |

		SChar |

		UChar |

		Short |

		UShort |

		Int |

		UInt |

		Long |

		ULong |

		LongInt |

		ULongInt |

		LongLong |

		ULongLong |

		Float |

		Double |

		LongDouble |

		Wchar_t |

		Utf8
}

type LangConfig

type LangConfig struct {
	IsLittleEndian bool
}

type Long

type Long int32

long

type LongDouble

type LongDouble float64

long double

type LongInt

type LongInt int64

long int

type LongLong

type LongLong int64

long long

type Numeric

type Numeric interface {
	int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64
}

type OnClosingCallback

type OnClosingCallback func() bool // 返回 false 拒绝关闭窗口

type OnConsoleCallback

type OnConsoleCallback func(level int, message, sourceName string, sourceLine int, stackTrace string)

type OnDestroyCallback

type OnDestroyCallback func()

type OnDidCreateScriptContextCallback

type OnDidCreateScriptContextCallback func(frame WkeWebFrameHandle, context uintptr, exGroup, worldId int)

type OnDocumentReadyCallback

type OnDocumentReadyCallback func(frame WkeWebFrameHandle)

type OnDomEventCallback

type OnDomEventCallback func()

type OnDownloadCallback

type OnDownloadCallback func(url string)

type OnLoadUrlBeginCallback

type OnLoadUrlBeginCallback func(url string, job WkeNetJob) bool

type OnLoadUrlEndCallback

type OnLoadUrlEndCallback func(url string, job WkeNetJob, buf []byte)

type OnOtherLoadCallback

type OnOtherLoadCallback func(loadType WkeOtherLoadType, info *WkeTempCallbackInfo)

type OnTitleChangedCallback

type OnTitleChangedCallback func(title string)

type OnWillReleaseScriptContextCallback

type OnWillReleaseScriptContextCallback func(frameId WkeWebFrameHandle, context uintptr, worldId int)

type PrintSettings

type PrintSettings struct {
	DPI          int
	Width        int // 单位 MM
	Height       int // 单位 MM
	MarginTop    int // 单位 MM
	MarginBottom int // 单位 MM
	MarginLeft   int // 单位 MM
	MarginRight  int // 单位 MM
}

type ProxyInfo

type ProxyInfo struct {
	Type     ProxyType
	HostName string
	Port     int
	UserName string
	Password string
}

type ProxyType

type ProxyType int
const (
	ProxyType_NONE ProxyType = iota
	ProxyType_HTTP
	ProxyType_SOCKS4
	ProxyType_SOCKS4A
	ProxyType_SOCKS5
	ProxyType_SOCKS5HOSTNAME
)

type SChar

type SChar int8

singed char

type SIZE_TYPE

type SIZE_TYPE uintptr
const (
	SIZE_RESTORED SIZE_TYPE = iota
	SIZE_MINIMIZED
	SIZE_MAXIMIZED
	SIZE_MAXSHOW
	SIZE_MAXHIDE
)

type Short

type Short int16

short

type UChar

type UChar uint8

unsigned char

type UInt

type UInt uint32

unsigned int

type ULong

type ULong uint32

unsigned long

type ULongInt

type ULongInt uint64

unsigned long int

type ULongLong

type ULongLong uint64

unsigned long long

type UShort

type UShort uint16

unsigned short

type Utf8

type Utf8 byte

utf8

type View

type View struct {
	Hwnd     WkeHandle
	Window   *Window
	DevTools *View
	// contains filtered or unexported fields
}

func NewView

func NewView(mb *Blink, hwnd WkeHandle, windowType WkeWindowType, parent ...*View) *View

func (*View) AddEventListener

func (v *View) AddEventListener(selector, eventType string, callback func(), preScripts ...string) (stop func())

JS.bind(".mb-minimize-btn", "click", func)

func (*View) CallJsFunc

func (v *View) CallJsFunc(funcName string, args ...interface{}) async.InProgress[interface{}]

func (*View) CloseWindow

func (v *View) CloseWindow()

func (*View) DestroyWindow

func (v *View) DestroyWindow()

销毁wkeWebView对应的所有数据结构,包括真实窗口等

func (*View) DoWhenDidCreateScriptContext

func (v *View) DoWhenDidCreateScriptContext(callback func())

仅作用于 主frame,会自动判断是否已创建 Script Context,仅执行一次

func (*View) DoWhenDocumentReady

func (v *View) DoWhenDocumentReady(callback func())

仅作用于 主frame,会自动判断是否 document ready,仅执行一次

func (*View) ForceReload

func (v *View) ForceReload()

func (*View) GetMainWebFrame

func (v *View) GetMainWebFrame() WkeWebFrameHandle

func (*View) GetRect

func (v *View) GetRect() *WkeRect

func (*View) GetURL

func (v *View) GetURL() string

func (*View) GetWindowHandle

func (v *View) GetWindowHandle() WkeHandle

func (*View) HideWindow

func (v *View) HideWindow()

func (*View) IsDidCreateScriptContext

func (v *View) IsDidCreateScriptContext() bool

func (*View) IsDocumentReady

func (v *View) IsDocumentReady() bool

func (*View) IsMainFrame

func (v *View) IsMainFrame(frameId WkeWebFrameHandle) bool

func (*View) LoadURL

func (v *View) LoadURL(url string)

func (*View) OnClosing

func (v *View) OnClosing(callback OnClosingCallback) (stop func())

可以添加多个 callback,将按照加入顺序依次执行

callback 返回 false 拒绝关闭窗口

func (*View) OnConsole

func (v *View) OnConsole(callback OnConsoleCallback) (stop func())

func (*View) OnDestroy

func (v *View) OnDestroy(callback OnDestroyCallback) (stop func())

可以添加多个 callback,将按照加入顺序依次执行

func (*View) OnDidCreateScriptContext

func (v *View) OnDidCreateScriptContext(callback OnDidCreateScriptContextCallback) (stop func())

func (*View) OnDocumentReady

func (v *View) OnDocumentReady(callback OnDocumentReadyCallback) (stop func())

func (*View) OnDownload

func (v *View) OnDownload(callback OnDownloadCallback) (stop func())

下载仅能使用一次,多次使用将覆盖前一个回调函数

func (*View) OnLoadUrlBegin

func (v *View) OnLoadUrlBegin(callback OnLoadUrlBeginCallback) (stop func())

func (*View) OnLoadUrlEnd

func (v *View) OnLoadUrlEnd(callback OnLoadUrlEndCallback) (stop func())

func (*View) OnOtherLoad

func (v *View) OnOtherLoad(callback OnOtherLoadCallback) (stop func())

func (*View) OnTitleChanged

func (v *View) OnTitleChanged(callback OnTitleChangedCallback) (stop func())

func (*View) OnWillReleaseScriptContext

func (v *View) OnWillReleaseScriptContext(callback OnWillReleaseScriptContextCallback) (stop func())

func (*View) Reload

func (v *View) Reload() bool

func (*View) RemoveEventListener

func (v *View) RemoveEventListener(selector, eventType string)

func (*View) Resize

func (v *View) Resize(width, height int32)

func (*View) RunJS

func (v *View) RunJS(script string) JsValue

仅作用于 主frame,会自动判断是否 document ready

func (*View) RunJsByFrame

func (v *View) RunJsByFrame(frame WkeWebFrameHandle, script string) JsValue

可指定 frame,会自动判断是否 document ready

func (*View) SaveToPDF

func (v *View) SaveToPDF(writer io.Writer, withSetting ...WithPrintSettings) error

保存主 WebFrame 的内容到 PDF

func (*View) SaveWebFrameToPDF

func (v *View) SaveWebFrameToPDF(frameId WkeWebFrameHandle, writer io.Writer, withSetting ...WithPrintSettings) error

保存指定 WebFrame 的内容到 PDF

func (*View) SetCookieJarFullPath

func (v *View) SetCookieJarFullPath(path string)

设置cookie的全路径+文件名,如“c:\mb\cookie.dat”

func (*View) SetHeadlessEnabled

func (v *View) SetHeadlessEnabled(enable bool) *CallFuncJob

func (*View) SetLocalStorageFullPath

func (v *View) SetLocalStorageFullPath(path string)

设置local storage的全路径。如“c:\mb\LocalStorage\” 注意:这个接口只能接受目录。

func (*View) SetTransparent

func (v *View) SetTransparent(transparent bool)

func (*View) ShowDevTools

func (v *View) ShowDevTools(devtoolsCallbacks ...func(devtools *View))

func (*View) ShowWindow

func (v *View) ShowWindow()

func (*View) WaitUntilDocumentReady

func (v *View) WaitUntilDocumentReady(timeout time.Duration) bool

阻塞等待文档加载完成,仅限主frame

type VoidPtr

type VoidPtr = uintptr

void *

type WM_SIZING

type WM_SIZING uintptr
const (
	WMSZ_LEFT        WM_SIZING = 1 // 左边缘
	WMSZ_RIGHT       WM_SIZING = 2 // 右边缘
	WMSZ_TOP         WM_SIZING = 3 // 上边缘
	WMSZ_TOPLEFT     WM_SIZING = 4 // 左上角
	WMSZ_TOPRIGHT    WM_SIZING = 5 // 右上角
	WMSZ_BOTTOM      WM_SIZING = 6 // 下边缘
	WMSZ_BOTTOMLEFT  WM_SIZING = 7 // 左下角
	WMSZ_BOTTOMRIGHT WM_SIZING = 8 // 右下角
)

type Wchar_t

type Wchar_t uint16

wchar_t

type WebWindowConfig

type WebWindowConfig struct {
	WkeRect
}

type Window

type Window struct {
	Hwnd WkeHandle
	// contains filtered or unexported fields
}

func (*Window) Close

func (w *Window) Close()

func (*Window) CloseAsHideTray

func (w *Window) CloseAsHideTray()

func (*Window) Destroy

func (w *Window) Destroy()

func (*Window) EnableBorderResize

func (w *Window) EnableBorderResize(enable bool, thicknessOpional ...int32)

开启边缘拖动大小功能

func (*Window) EnableDragging

func (w *Window) EnableDragging()

func (*Window) EnableTray

func (w *Window) EnableTray(setups ...func(*win.NOTIFYICONDATA))

func (*Window) Hide

func (w *Window) Hide()

func (*Window) HideCaption

func (w *Window) HideCaption()

隐藏标题栏

func (*Window) IsMaximized

func (w *Window) IsMaximized() bool

func (*Window) Maximize

func (w *Window) Maximize()

func (*Window) Minimize

func (w *Window) Minimize()

func (*Window) MinimizeToTray

func (w *Window) MinimizeToTray()

func (*Window) Move

func (w *Window) Move(x, y int32)

func (*Window) MoveToCenter

func (w *Window) MoveToCenter()

func (*Window) OnActivateApp

func (w *Window) OnActivateApp(callback WindowOnActivateAppCallback) (stop func())

Active APP 事件

func (*Window) OnCreate

func (w *Window) OnCreate(callback WindowOnCreateCallback) (stop func())

Create 事件

func (*Window) OnSize

func (w *Window) OnSize(callback WindowOnSizeCallback) (stop func())

Size 事件

func (*Window) OnSizing

func (w *Window) OnSizing(callback WindowOnSizingCallback) (stop func())

Sizing 事件

func (*Window) RemoveTray

func (w *Window) RemoveTray()

func (*Window) Resize

func (w *Window) Resize(width, height int32)

func (*Window) Restore

func (w *Window) Restore()

func (*Window) SetIcon

func (w *Window) SetIcon(handle win.HANDLE) error

func (*Window) SetIconFromBytes

func (w *Window) SetIconFromBytes(iconData []byte) error

设置窗口图标(从图标二进制数据中). 快捷方法

func (*Window) SetIconFromFile

func (w *Window) SetIconFromFile(iconFilePath string) error

设置窗口图标(从图标文件中). 快捷方法

func (*Window) SetTitle

func (w *Window) SetTitle(title string)

func (*Window) SetWindowPos

func (w *Window) SetWindowPos(x, y, width, height int32)

修改窗口大小

func (*Window) Show

func (w *Window) Show()

func (*Window) ShowCaption

func (w *Window) ShowCaption()

显示标题栏

type WindowOnActivateAppCallback

type WindowOnActivateAppCallback func(bool, uintptr)

type WindowOnCreateCallback

type WindowOnCreateCallback func(*win.CREATESTRUCT)

type WindowOnSizeCallback

type WindowOnSizeCallback func(stype SIZE_TYPE, width, height uint16)

type WindowOnSizingCallback

type WindowOnSizingCallback func(WM_SIZING, *win.RECT)

type WithPrintSettings

type WithPrintSettings func(s *PrintSettings)

type WithWebWindowConfig

type WithWebWindowConfig func(c *WebWindowConfig)

func WithWebWindowPos

func WithWebWindowPos(x, y int32) WithWebWindowConfig

设置窗口位置

func WithWebWindowSize

func WithWebWindowSize(w, h int32) WithWebWindowConfig

设置窗口大小

type WkeConsoleCallback

type WkeConsoleCallback func(view WkeHandle, param uintptr, level WkeConsoleLevel, message, sourceName WkeString, sourceLine uint32, stackTrace WkeString) (voidRes uintptr)

type WkeConsoleLevel

type WkeConsoleLevel int
const (
	WkeConsoleLevel_Log WkeConsoleLevel = iota + 1
	WkeConsoleLevel_Warning
	WkeConsoleLevel_Error
	WkeConsoleLevel_Debug
	WkeConsoleLevel_Info
	WkeConsoleLevel_RevokedError
)

type WkeCreateViewCallback

type WkeCreateViewCallback func(webView WkeHandle, param uintptr, navigationType WkeNavigationType, url WkeString, windowFeatures *WkeWindowFeatures) WkeHandle

type WkeCursorType

type WkeCursorType int
const (
	WkeCursorType_Pointer WkeCursorType = iota
	WkeCursorType_Cross
	WkeCursorType_Hand
	WkeCursorType_IBeam
	WkeCursorType_Wait
	WkeCursorType_Help
	WkeCursorType_EastResize
	WkeCursorType_NorthResize
	WkeCursorType_NorthEastResize
	WkeCursorType_NorthWestResize
	WkeCursorType_SouthResize
	WkeCursorType_SouthEastResize
	WkeCursorType_SouthWestResize
	WkeCursorType_WestResize
	WkeCursorType_NorthSouthResize
	WkeCursorType_EastWestResize
	WkeCursorType_NorthEastSouthWestResize
	WkeCursorType_NorthWestSouthEastResize
	WkeCursorType_ColumnResize
	WkeCursorType_RowResize
	WkeCursorType_MiddlePanning
	WkeCursorType_EastPanning
	WkeCursorType_NorthPanning
	WkeCursorType_NorthEastPanning
	WkeCursorType_NorthWestPanning
	WkeCursorType_SouthPanning
	WkeCursorType_SouthEastPanning
	WkeCursorType_SouthWestPanning
	WkeCursorType_WestPanning
	WkeCursorType_Move
	WkeCursorType_VerticalText
	WkeCursorType_Cell
	WkeCursorType_ContextMenu
	WkeCursorType_Alias
	WkeCursorType_Progress
	WkeCursorType_NoDrop
	WkeCursorType_Copy
	WkeCursorType_None
	WkeCursorType_NotAllowed
	WkeCursorType_ZoomIn
	WkeCursorType_ZoomOut
	WkeCursorType_Grab
	WkeCursorType_Grabbing
	WkeCursorType_Custom
)

type WkeDidCreateScriptContextCallback

type WkeDidCreateScriptContextCallback func(view WkeHandle, param uintptr, frame WkeWebFrameHandle, context uintptr, exGroup, worldId int) (voidRes uintptr)

type WkeDocumentReady2Callback

type WkeDocumentReady2Callback func(view WkeHandle, param uintptr, frame WkeWebFrameHandle) (voidRes uintptr)

type WkeDownloadCallback

type WkeDownloadCallback func(view WkeHandle, param uintptr, url uintptr) (voidRes uintptr)

type WkeHandle

type WkeHandle uintptr

type WkeHttBodyElementType

type WkeHttBodyElementType int

枚举类型

const (
	WkeHttBodyElementTypeData WkeHttBodyElementType = iota
	WkeHttBodyElementTypeFile
)

type WkeJsNativeFunction

type WkeJsNativeFunction func(es JsExecState, param uintptr) (voidRes uintptr)

type WkeKeyFlags

type WkeKeyFlags int
const (
	WkeKeyFlags_Extend WkeKeyFlags = 0x0100
	WkeKeyFlags_Repeat WkeKeyFlags = 0x4000
)

type WkeLoadUrlBeginCallback

type WkeLoadUrlBeginCallback func(view WkeHandle, param uintptr, url string, job WkeNetJob) (boolRes uintptr)

type WkeLoadUrlEndCallback

type WkeLoadUrlEndCallback func(view WkeHandle, param uintptr, url string, job WkeNetJob, buf []byte) (voidRes uintptr)

type WkeLoadUrlFailCallback

type WkeLoadUrlFailCallback func(view WkeHandle, param, url string, job WkeNetJob) (voidRes uintptr)

type WkeMemBuf

type WkeMemBuf struct {
	Unuse  int
	Data   unsafe.Pointer // 使用unsafe.Pointer代替void*
	Length uintptr        // 使用uintptr代替size_t(如果Length的值不会超过int的范围,也可以使用int)
}

wkeMemBuf 结构体

type WkeMouseFlags

type WkeMouseFlags int
const (
	WkeMouseFlags_None    WkeMouseFlags = 0
	WkeMouseFlags_LBUTTON WkeMouseFlags = 0x01
	WkeMouseFlags_RBUTTON WkeMouseFlags = 0x02
	WkeMouseFlags_SHIFT   WkeMouseFlags = 0x04
	WkeMouseFlags_CONTROL WkeMouseFlags = 0x08
	WkeMouseFlags_MBUTTON WkeMouseFlags = 0x10
)

type WkeNavigationType

type WkeNavigationType int
const (
	WKE_NAVIGATION_TYPE_LINKCLICK WkeNavigationType = iota
	WKE_NAVIGATION_TYPE_FORMSUBMITTED
	WKE_NAVIGATION_TYPE_BACKFORWARD
	WKE_NAVIGATION_TYPE_RELOAD
	WKE_NAVIGATION_TYPE_FORMRESUBMITTED
	WKE_NAVIGATION_TYPE_OTHER
)

type WkeNetJob

type WkeNetJob uintptr

type WkeNetResponseCallback

type WkeNetResponseCallback func(view WkeHandle, param uintptr, url string, job WkeNetJob) (boolRes uintptr)

type WkeOnOtherLoadCallback

type WkeOnOtherLoadCallback func(webView WkeHandle, param uintptr, loadType WkeOtherLoadType, info *WkeTempCallbackInfo) (voidRes uintptr)

type WkeOnShowDevtoolsCallback

type WkeOnShowDevtoolsCallback func(view WkeHandle, param uintptr) (voidRes uintptr)

type WkeOtherLoadType

type WkeOtherLoadType int
const (
	WKE_DID_START_LOADING WkeOtherLoadType = iota
	WKE_DID_STOP_LOADING
	WKE_DID_NAVIGATE
	WKE_DID_NAVIGATE_IN_PAGE
	WKE_DID_GET_RESPONSE_DETAILS
	WKE_DID_GET_REDIRECT_REQUEST
	WKE_DID_POST_REQUEST
)

type WkePaintBitUpdatedCallback

type WkePaintBitUpdatedCallback func(view WkeHandle, param, buf []byte, rect *WkeRect, width, height int32) (voidRes uintptr)

type WkePostBodyElement

type WkePostBodyElement struct {
	Size       int
	Type       WkeHttBodyElementType
	Data       *WkeMemBuf // 假设WkeMemBuf是指针类型
	FilePath   WkeString  // 使用uintptr代替C中的wkeString
	FileStart  int64
	FileLength int64 // -1 表示到文件末尾
}

wkePostBodyElement 结构体

type WkePostBodyElements

type WkePostBodyElements struct {
	Size        int
	Elements    []*WkePostBodyElement // 使用切片代替指针的指针和大小
	ElementSize uintptr
	IsDirty     bool
}

wkePostBodyElements 结构体(使用Go的切片)

type WkeRect

type WkeRect struct {
	X, Y, W, H int32
}

type WkeRequestType

type WkeRequestType int
const (
	WkeRequestType_Unknow WkeRequestType = iota + 1
	WkeRequestType_Get
	WkeRequestType_Post
	WkeRequestType_Put
)

type WkeResourceType

type WkeResourceType int

枚举类型

const (
	WKE_RESOURCE_TYPE_MAIN_FRAME WkeResourceType = iota
	WKE_RESOURCE_TYPE_SUB_FRAME
	WKE_RESOURCE_TYPE_STYLESHEET
	WKE_RESOURCE_TYPE_SCRIPT
	WKE_RESOURCE_TYPE_IMAGE
	WKE_RESOURCE_TYPE_FONT_RESOURCE
	WKE_RESOURCE_TYPE_SUB_RESOURCE
	WKE_RESOURCE_TYPE_OBJECT
	WKE_RESOURCE_TYPE_MEDIA
	WKE_RESOURCE_TYPE_WORKER
	WKE_RESOURCE_TYPE_SHARED_WORKER
	WKE_RESOURCE_TYPE_PREFETCH
	WKE_RESOURCE_TYPE_FAVICON
	WKE_RESOURCE_TYPE_XHR
	WKE_RESOURCE_TYPE_PING
	WKE_RESOURCE_TYPE_SERVICE_WORKER
	WKE_RESOURCE_TYPE_LAST_TYPE
)

type WkeSlist

type WkeSlist struct {
	Str  uintptr
	Next uintptr
}

type WkeString

type WkeString uintptr

type WkeTempCallbackInfo

type WkeTempCallbackInfo struct {
	Size                int
	Frame               WkeWebFrameHandle
	WillSendRequestInfo *WkeWillSendRequestInfo
	URL                 *byte // 在Go中,使用*byte代替const char* (如果字符串以null结尾)
	PostBody            *WkePostBodyElements
	Job                 WkeNetJob
}

type WkeTitleChangedCallback

type WkeTitleChangedCallback func(view WkeHandle, param uintptr, title WkeString) (voidRes uintptr)

type WkeWebFrameHandle

type WkeWebFrameHandle uintptr

type WkeWillReleaseScriptContextCallback

type WkeWillReleaseScriptContextCallback func(webView WkeHandle, param uintptr, frameId WkeWebFrameHandle, context uintptr, worldId int) (voidRes uintptr)

type WkeWillSendRequestInfo

type WkeWillSendRequestInfo struct {
	URL              WkeString
	NewURL           WkeString
	ResourceType     WkeResourceType
	HTTPResponseCode int
	Method           WkeString
	Referrer         WkeString
	Headers          unsafe.Pointer // 使用unsafe.Pointer代替C中的void*
}

type WkeWindowClosingCallback

type WkeWindowClosingCallback func(view WkeHandle, param uintptr) (boolRes uintptr)

type WkeWindowDestroyCallback

type WkeWindowDestroyCallback func(view WkeHandle, param uintptr) (voidRes uintptr)

type WkeWindowFeatures

type WkeWindowFeatures struct {
	X      int // 窗口x坐标
	Y      int // 窗口y坐标
	Width  int // 窗口宽度
	Height int // 窗口高度

	MenuBarVisible     bool // 是否显示菜单栏
	StatusBarVisible   bool // 是否显示状态栏
	ToolBarVisible     bool // 是否显示工具栏
	LocationBarVisible bool // 是否显示地址栏
	ScrollbarsVisible  bool // 是否显示滚动条
	Resizable          bool // 是否可调整大小
	Fullscreen         bool // 是否全屏显示
}

type WkeWindowType

type WkeWindowType uintptr
const (
	// 普通窗口
	WKE_WINDOW_TYPE_POPUP WkeWindowType = iota
	// 透明窗口。mb内部通过layer window实现
	WKE_WINDOW_TYPE_TRANSPARENT
	// 嵌入在父窗口里的子窗口。此时parent需要被设置
	WKE_WINDOW_TYPE_CONTROL
	// 隐藏标题栏
	WKE_WINDOW_TYPE_HIDE_CAPTION
)

Directories

Path Synopsis
internal
env
log
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL