go_chrome

package module
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 20 Imported by: 1

README

####中文 | English

目前仅支持 Mac X86 编译 win,win X86 编译 win

  1. 基于 chromedp 的一个以Html为界面Golang为后端的简单GUI包
  2. 可以选择带chrome内核打包可执行程序,不带chrome内核打包可执行程序
  3. 完全支持 chromedp 所有方法
  4. 支持自启Http服务,无服务渲染文件,打开远程地址
  5. javaScript与Golang间通信参考了zserge/lorca
  6. 使用方法 go-chrome-demo
  7. 打包程序 go-chrome-build

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChromeRunCommand map[string]interface{} = map[string]interface{}{
	"disable-background-networking":          true,
	"disable-background-timer-throttling":    true,
	"disable-backgrounding-occluded-windows": true,
	"disable-breakpad":                       true,
	"disable-client-side-phishing-detection": true,
	"disable-default-apps":                   true,
	"disable-dev-shm-usage":                  true,
	"disable-infobars":                       true,
	"disable-extensions":                     true,
	"disable-hang-monitor":                   true,
	"disable-ipc-flooding-protection":        true,
	"disable-popup-blocking":                 true,
	"disable-prompt-on-repost":               true,
	"disable-renderer-backgrounding":         true,
	"disable-sync":                           true,
	"disable-translate":                      true,
	"disable-windows10-custom-titlebar":      true,
	"metrics-recording-only":                 true,
	"no-first-run":                           true,
	"no-default-browser-check":               true,
	"safebrowsing-disable-auto-update":       true,
	"enable-automation":                      false,
	"password-store":                         "basic",
	"use-mock-keychain":                      true,
}

ChromeRunCommand 浏览器启动命令

Functions

func GetBrowserPath added in v1.1.0

func GetBrowserPath(opt *GoChromeOptions) (string, error)

func GetHomePath added in v1.1.0

func GetHomePath() string

func IsExist

func IsExist(fileAddr string) bool

IsExist 判断文件是否存在

func ReleaseBrowser

func ReleaseBrowser(opt *GoChromeOptions) error

func UnPackZip added in v1.1.0

func UnPackZip(src, dest string) error

Types

type ActionTask

type ActionTask chromedp.Tasks

type GoChrome

type GoChrome struct {
	Url               string
	ContextContext    context.Context
	ContextCancelFunc context.CancelFunc

	Action chromedp.Tasks

	GoHttp *goHttp
	// contains filtered or unexported fields
}

func Create

func Create(url string, opt ...GoChromeOptions) *GoChrome

func (*GoChrome) Bind

func (gc *GoChrome) Bind(jsFuncName string, f interface{}) error

func (*GoChrome) Close

func (gc *GoChrome) Close()

func (*GoChrome) JsFunc

func (gc *GoChrome) JsFunc(funcName string, args ...string) reflect.Value

func (*GoChrome) ListenBrowser

func (gc *GoChrome) ListenBrowser(fn func(ev interface{}))

func (*GoChrome) ListenTarget

func (gc *GoChrome) ListenTarget(fn func(ev interface{}))

func (*GoChrome) OpenAfter

func (gc *GoChrome) OpenAfter(f func())

func (*GoChrome) Run

func (gc *GoChrome) Run()

func (*GoChrome) RunUnBackup added in v1.1.6

func (gc *GoChrome) RunUnBackup() error

func (*GoChrome) SetAction

func (gc *GoChrome) SetAction(actionArr ActionTask)

type GoChromeOptions

type GoChromeOptions struct {
	AppName              string // 应用名称
	CliModule            bool   // 命令行模式
	AppModule            bool   // 应用模式启动
	WindowWidth          int    // 宽度
	WindowHeight         int    // 高度
	WindowPositionWidth  int    // 横向位置
	WindowPositionHeight int    // 竖向位置
	UseHttpServer        bool   // 是否使用http服务
	HttpPort             int    // http服务的端口

	HttpRoute                 map[string]func(http.ResponseWriter, *http.Request) // 额外的http路由
	AssetFile                 http.FileSystem                                     // 静态资源
	RestoreAssets             func(dir, name string) error                        // 解压资源方法
	ChromeExecAllocatorOption []chromedp.ExecAllocatorOption                      // 启动参数
	// contains filtered or unexported fields
}

GoChromeOptions 启动配置

type PackageConf

type PackageConf struct {
	Name              string   `json:"name"`
	ChromeExecPath    string   `json:"chrome_exec_path"`
	IntegratedBrowser bool     `json:"integrated_browser"`
	ChromePackPath    Platform `json:"chrome_pack_path"`
	ChromeVersion     Platform `json:"chrome_version"`
	BuildCachePath    string   `json:"build_cache_path"`
	Icons             Platform `json:"icons"`
	RunBuildPath      string   `json:"run_build_path"`
}

type Platform

type Platform struct {
	Linux   string `json:"linux"`
	Windows string `json:"windows"`
	Darwin  string `json:"darwin"`
}

Jump to

Keyboard shortcuts

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