Migrated repository
Go to file
2022-10-18 13:26:17 +08:00
cef 升级 golcl 2022-10-07 01:31:12 +08:00
commons README.zh-CN.md 2022-10-06 15:41:33 +08:00
consts 包结构修改 2022-10-04 22:34:57 +08:00
decimal go datetme d datetime 2022-10-05 15:33:17 +08:00
example mac os ipc 使用 unix socket 2022-10-18 10:12:56 +08:00
ipc mac os ipc 使用 unix socket 2022-10-18 10:12:56 +08:00
logger logger 2022-10-05 21:06:29 +08:00
.gitattributes 增加示例使用和注释说明 2022-10-05 20:37:20 +08:00
.gitignore rm *.syso 2022-10-04 13:38:14 +08:00
go.mod v1.0.0 2022-10-18 13:26:17 +08:00
go.sum v1.0.0 2022-10-18 13:26:17 +08:00
LICENSE Initial commit 2022-10-04 00:30:09 +08:00
README.en-US.md README.md 2022-10-06 20:04:16 +08:00
README.md v1.0.0 2022-10-18 13:26:17 +08:00

Energy is Go's framework for building desktop applications based on CEF

中文 | English


Introduction

Energy Is a framework for building desktop applications using JavaScript,HTML, and CSS based on Golcl and CEF4Delphi Pure Go language development framework, embedded Chromium CEF binary

Lets you use Web front-end development techniques to build cross-platform applications on Windows, Linux, and MacOS

You can also use the Energy and Golcl Build applications that use system-level native UI and cross platform with Web front-end technology

Supports Windows_32, 64 bits, Linux_x86_64 bits, MacOS_x86_64 bits

CEF(105.3.39)Binary download

Getting started guide

Quick start

Basic needs

golang >= 1.9.2

Download the CEF binary package for the corresponding platform and version, and decompress it to the directory.

Example/simple example

Install Energy dependencies go get github.com/energye/energy

Or use: go mod init, go mod tidy

run simple

The packaging application Energy does not have packaging modules, Windows you can use (MSI or Inno Setup) and other green packaging tools, Deb installation package in Linux, MacOS generates. App packages by default or custom. App packages

example/simple code
package main

import (
	"embed"
	"fmt"
	"github.com/energye/energy/cef"
	"github.com/energye/golcl/lcl"
)

//go:embed resources
var resources embed.FS

//这是一个简单的窗口创建示例
func main() {
	//全局初始化 每个应用都必须调用的
	cef.GlobalCEFInit(nil, &resources)
	//可选的应用配置
	cfg := cef.NewApplicationConfig()
	//指定chromium的二进制包框架根目录, 不指定为当前程序执行目录
	cfg.SetFrameworkDirPath("/xxxx/xxxx/chromium")
	//创建应用
	cefApp := cef.NewApplication(cfg)
	//主窗口的配置
	//指定一个URL地址或本地html文件目录
	cef.BrowserWindow.Config.DefaultUrl = "https://energy.yanghy.cn"
	//窗口的标题
	cef.BrowserWindow.Config.Title = "energy - 这是一个简单的窗口示例"
	//窗口宽高
	cef.BrowserWindow.Config.Width = 1024
	cef.BrowserWindow.Config.Height = 768
	//chromium配置
	cef.BrowserWindow.Config.SetChromiumConfig(cef.NewChromiumConfig())
	//通过创建窗口时的回调函数 对浏览器事件设置,和窗口属性组件等创建和修改
	cef.BrowserWindow.SetBrowserInit(func(event *cef.BrowserEvent, browserWindow *cef.TCefWindowInfo) {
		//设置应用图标 这里加载的图标是内置到执行程序里的资源文件
		lcl.Application.Icon().LoadFromFSFile("resources/icon.ico")
		fmt.Println("SetBrowserInit")
	})
	//通过创建窗口之后对对主窗口的属性、组件或子创建的创建
	cef.BrowserWindow.SetBrowserInitAfter(func(browserWindow *cef.TCefWindowInfo) {
		fmt.Println("SetBrowserInitAfter")
	})
	//运行应用
	cef.Run(cefApp)
}

Installation

  • Download the binary package for the corresponding platform and energy version
  • Install Energy dependencies go get github.com/energye/energy Or use: go mod init, go mod tidy
  • Create a GO application, see the Getting Started Guide and Example