GoMiniblink

package module
v0.0.0-...-7a3d1ee Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 17 Imported by: 0

README

介绍

Miniblink的免费版封装,官网:https://miniblink.net/

  1. 不使用CGO
  2. 面向对象
  3. 跨平台设计,但目前只有一个windows实现
  4. 组件和窗体两种模式
  5. JS互操作
  6. 监控与拦截请求
  7. 透明窗体
  8. 支持本地目录加载模式

Go封装的功能比较少,其实就是 https://gitee.com/aochulai/NetMiniblink 的简化版,因为我出Go封装的目标是VIP,所以免费版就懒得像NetMiniblink一样写得那么完善啦,不过VIP版会向NetMiniblink完整度看齐。

简单的例子
package main

import (
	gm "gitee.com/aochulai/GoMiniblink"
	cs "gitee.com/aochulai/GoMiniblink/forms/controls"
	ws "gitee.com/aochulai/GoMiniblink/forms/windows"
)

func main() {
    //windows版本初始化
    cs.App = new(ws.Provider).Init()
    
    //创建一个窗体并设置基本属性
    frm := new(cs.Form).Init()
    frm.SetTitle("普通窗口")
    frm.SetSize(800, 500)
	
    //创建浏览器控件并设置基本属性
    mb := new(gm.MiniblinkBrowser).Init()
    mb.SetSize(700, 400)
    
    //添加浏览器控件到窗体
    frm.AddChild(mb)
    //注册回调, EvLoad回调在窗体首次显示前触发
    frm.EvLoad["回调名称"] = func(s cs.GUI) {
        //加载网址
        mb.LoadUri("https://www.baidu.com")
    }
    //将frm作为主窗口打开
    cs.Run(frm)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindJsFunc

func BindJsFunc(fn JsFnBinding)

Types

type ConsoleCallback

type ConsoleCallback func(args ConsoleEvArgs)

type ConsoleEvArgs

type ConsoleEvArgs interface {
	Level() string
	Message() string
	SourceName() string
	SourceLine() int
	StackTrace() string
}

type DocumentReadyCallback

type DocumentReadyCallback func(args DocumentReadyEvArgs)

type DocumentReadyEvArgs

type DocumentReadyEvArgs interface {
	FrameContext
}

type EventDispatcher

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

func (*EventDispatcher) Add

func (_this *EventDispatcher) Add(name string, fn interface{})

func (*EventDispatcher) AddEx

func (_this *EventDispatcher) AddEx(fn interface{}) string

func (*EventDispatcher) Clear

func (_this *EventDispatcher) Clear()

func (*EventDispatcher) Fire

func (_this *EventDispatcher) Fire(key string, sender interface{}, param ...interface{})

func (*EventDispatcher) Init

func (_this *EventDispatcher) Init(key string) *EventDispatcher

func (*EventDispatcher) IsEmtpy

func (_this *EventDispatcher) IsEmtpy() bool

func (*EventDispatcher) Remove

func (_this *EventDispatcher) Remove(name string) interface{}

type FileLoader

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

func (*FileLoader) ByUri

func (_this *FileLoader) ByUri(uri *url2.URL) []byte

func (*FileLoader) Domain

func (_this *FileLoader) Domain() string

func (*FileLoader) Init

func (_this *FileLoader) Init(dir, domain string) *FileLoader

type FrameContext

type FrameContext interface {
	FrameId() uintptr
	IsMain() bool
	Url() string
	IsRemote() bool
	RunJs(script string) interface{}
}

type GoFn

type GoFn func(context GoFnContext) interface{}

type GoFnContext

type GoFnContext struct {
	Miniblink Miniblink
	Name      string
	State     interface{}
	Param     []interface{}
}

type JsFnBinding

type JsFnBinding struct {
	Name  string
	Fn    GoFn
	State interface{}
	// contains filtered or unexported fields
}

func (*JsFnBinding) Call

func (_this *JsFnBinding) Call(mb Miniblink, param []interface{}) interface{}

type JsFunc

type JsFunc func(param ...interface{}) interface{}

type JsReadyCallback

type JsReadyCallback func(args JsReadyEvArgs)

type JsReadyEvArgs

type JsReadyEvArgs interface {
	FrameContext
}

type LoadFailEvArgs

type LoadFailEvArgs interface {
	RequestBefore() RequestBeforeEvArgs
}

type LoadResource

type LoadResource interface {
	Domain() string
	ByUri(uri *url2.URL) []byte
}
type Miniblink interface {
	SetBmpPaintMode(b bool)
	SetProxy(info ProxyInfo)
	MouseIsEnable() bool
	MouseEnable(b bool)
	ToBitmap() *image.RGBA
	CallJsFunc(name string, param []interface{}) interface{}
	JsFunc(name string, fn GoFn, state interface{})
	RunJs(script string) interface{}
	SetOnConsole(callback ConsoleCallback)
	SetOnJsReady(callback JsReadyCallback)
	SetOnRequestBefore(callback RequestBeforeCallback)
	SetOnDocumentReady(callback DocumentReadyCallback)
	SetOnPaintUpdated(callback PaintUpdatedCallback)
	LoadUri(uri string)
	GetHandle() wkeHandle
}

type MiniblinkBrowser

type MiniblinkBrowser struct {
	cs.Control

	EvRequestBefore map[string]func(sender *MiniblinkBrowser, e RequestBeforeEvArgs)
	OnRequestBefore func(e RequestBeforeEvArgs)

	EvJsReady map[string]func(sender *MiniblinkBrowser, e JsReadyEvArgs)
	OnJsReady func(e JsReadyEvArgs)

	EvConsole map[string]func(sender *MiniblinkBrowser, e ConsoleEvArgs)
	OnConsole func(e ConsoleEvArgs)

	EvDocumentReady map[string]func(sender *MiniblinkBrowser, e DocumentReadyEvArgs)
	OnDocumentReady func(e DocumentReadyEvArgs)

	EvPaintUpdated map[string]func(sender *MiniblinkBrowser, e PaintUpdatedEvArgs)
	OnPaintUpdated func(e PaintUpdatedEvArgs)

	ResourceLoader []LoadResource
	// contains filtered or unexported fields
}

func (*MiniblinkBrowser) CallJsFunc

func (_this *MiniblinkBrowser) CallJsFunc(name string, param ...interface{}) interface{}

func (*MiniblinkBrowser) GetMiniblinkHandle

func (_this *MiniblinkBrowser) GetMiniblinkHandle() uintptr

func (*MiniblinkBrowser) Init

func (_this *MiniblinkBrowser) Init() *MiniblinkBrowser

func (*MiniblinkBrowser) JsFunc

func (_this *MiniblinkBrowser) JsFunc(name string, fn GoFn, state interface{})

func (*MiniblinkBrowser) JsFuncEx

func (_this *MiniblinkBrowser) JsFuncEx(name string, fn interface{})

func (*MiniblinkBrowser) LoadUri

func (_this *MiniblinkBrowser) LoadUri(uri string)

func (*MiniblinkBrowser) MouseEnable

func (_this *MiniblinkBrowser) MouseEnable(b bool)

func (*MiniblinkBrowser) MouseIsEnable

func (_this *MiniblinkBrowser) MouseIsEnable() bool

func (*MiniblinkBrowser) SetBmpPaintMode

func (_this *MiniblinkBrowser) SetBmpPaintMode(b bool)

func (*MiniblinkBrowser) SetProxy

func (_this *MiniblinkBrowser) SetProxy(info ProxyInfo)

func (*MiniblinkBrowser) ToBitmap

func (_this *MiniblinkBrowser) ToBitmap() *image.RGBA

type MiniblinkForm

type MiniblinkForm struct {
	cs.Form
	View *MiniblinkBrowser
	// contains filtered or unexported fields
}

func (*MiniblinkForm) Init

func (_this *MiniblinkForm) Init() *MiniblinkForm

func (*MiniblinkForm) InitEx

func (_this *MiniblinkForm) InitEx(param br.FormParam) *MiniblinkForm

func (*MiniblinkForm) TransparentMode

func (_this *MiniblinkForm) TransparentMode()

type PaintUpdatedCallback

type PaintUpdatedCallback func(args PaintUpdatedEvArgs)

type PaintUpdatedEvArgs

type PaintUpdatedEvArgs interface {
	Bitmap() *image.RGBA
	Bound() forms.Bound
	Cancel()
	IsCancel() bool
}

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 RequestBeforeCallback

type RequestBeforeCallback func(args RequestBeforeEvArgs)

type RequestBeforeEvArgs

type RequestBeforeEvArgs interface {
	Url() string
	Method() string
	SetData([]byte)
	Data() []byte
	SetCancel(b bool)
	ResetUrl(url string)
	SetHeader(name, value string)
	/**
	内容最终呈现时触发
	args:intf, ResponseEvArgs
	*/
	EvResponse() *EventDispatcher
	/**
	加载失败时触发
	args:intf, LoadFailEvArgs
	*/
	EvLoadFail() *EventDispatcher
	/**
	请求流程全部完成时触发
	args:intf, RequestBeforeEvArgs
	*/
	EvFinish() *EventDispatcher
}

type ResponseCallback

type ResponseCallback func(args ResponseEvArgs)

type ResponseEvArgs

type ResponseEvArgs interface {
	RequestBefore() RequestBeforeEvArgs
	ContentType() string
	SetContentType(contentType string)
	Data() []byte
	SetData(data []byte)
	Headers() map[string]string
}

Directories

Path Synopsis
Res

Jump to

Keyboard shortcuts

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