提交 abde5bf2 编写于 作者: yanghye's avatar yanghye

A: add demo build-examples, build examples exe to dist

上级 cd35a0df
......@@ -123,3 +123,5 @@ rsrc
bytes.txt
*.icns
icons.iconset/
dist
......@@ -46,7 +46,7 @@ func syso() error {
syso := winRes.NewSYSO()
// 设置命令行执行目录, 该目录是要生成图标的应用根目录
// 资源在 resources 目录中读取
syso.CMDDir = filepath.Join(wd(), "example", "lib-checkupdate")
syso.CMDDir = filepath.Join(wd(), "example", "control")
syso.IconName = "icon.ico"
return syso.RC()
}
package main
import (
"github.com/energye/golcl/tools/command"
"os"
"path/filepath"
"runtime"
)
func main() {
const (
isWindows = runtime.GOOS == "windows" //support
isLinux = runtime.GOOS == "linux" //support
isDarwin = runtime.GOOS == "darwin" //support
)
wd, _ := os.Getwd()
println("current:", wd)
dist := filepath.Join(wd, "example", "dist")
if !isExist(dist) {
os.MkdirAll(dist, os.ModePerm)
}
examples := []string{"context-menu", "control", "cookie", "cookie-manager", "custom-drag-window", "dev-tools",
"dom-visitor", "download", "drag-file", "execute-dev-tools-method", "execute-javascript", "flash-for-cef-v87",
"frameless", "i18n", "internal-http-server", "ipc-on-emit/go-composite-type", "ipc-on-emit/go-to-js", "ipc-on-emit/js-to-go",
"key-event", "lib-checkupdate", "load-html-url",
"msgbox", "osr/linux", "osr/windows", "popup-sub-window", "print-pdf", "process-type", "proxy", "response-filter",
"scheme", "screen", "search-text", "simple", "sub-process/main-process", "sub-process/sub-process", "sys-dialog",
"sys-menu", "tempdll", "view-source", "vue",
"webkit-register", "zoom"}
var (
ext string
ldflags string
)
if isWindows {
examples = append(examples, "windows/custom-browser-create", "windows/transparent")
examples = append(examples, "tray/lclceftray", "tray/lcltray", "tray/systray", "tray/lclvftray")
ext = ".exe"
ldflags = `-H windowsgui -s -w`
} else if isLinux || isDarwin {
examples = append(examples, "tray/lcltray", "tray/systray")
ldflags = `-s -w`
}
cmd := command.NewCMD()
for _, example := range examples {
dir := filepath.Join(wd, "example", example)
if isExist(dir) {
cmd.Dir = dir
out := filepath.Join(dist, example+ext)
println("build example", example, "\n\tbuild-dir:", dir, "\n\tout-dir:", out)
cmd.Command("go", "build", "-ldflags", ldflags, "-o", out, `-tags=tempdll`)
println()
} else {
println("not found:", dir)
}
}
cmd.Close()
println("build end.")
}
func isExist(path string) bool {
_, err := os.Stat(path)
if err != nil {
if os.IsExist(err) {
return true
} else if os.IsNotExist(err) {
return false
}
return false
}
return true
}
//go:build !windows
package main
const (
syso = false
)
var sysoBytesAMD64 []byte
var sysoBytes386 []byte
//go:build windows
package main
const (
syso = true
)
var sysoBytesAMD64 []byte
var sysoBytes386 []byte
......@@ -27,7 +27,7 @@ func main() {
//主窗口的配置
//指定一个URL地址,或本地html文件目录
cef.BrowserWindow.Config.Url = "http://localhost:22022/cookie.html"
if common.IsLinux() && app.IsUIGtk3() {
if common.IsLinux() && cefApp.IsUIGtk3() {
cef.BrowserWindow.Config.IconFS = "resources/icon.png"
} else {
cef.BrowserWindow.Config.IconFS = "resources/icon.ico"
......
......@@ -27,12 +27,13 @@ func main() {
loadEnergyUrl consts.MenuId
loadBaiduUrl consts.MenuId
)
event.SetOnBeforeContextMenu(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, params *cef.ICefContextMenuParams, model *cef.ICefMenuModel) {
event.SetOnBeforeContextMenu(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, params *cef.ICefContextMenuParams, model *cef.ICefMenuModel) bool {
model.AddSeparator()
loadEnergyUrl = model.CefMis.NextCommandId()
model.AddCheckItem(loadEnergyUrl, "load-energy")
loadBaiduUrl = model.CefMis.NextCommandId()
model.AddCheckItem(loadBaiduUrl, "load-baidu")
return false
})
event.SetOnContextMenuCommand(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, params *cef.ICefContextMenuParams, commandId consts.MenuId, eventFlags uint32, result *bool) {
if commandId == loadEnergyUrl {
......
### 窗口状态示例
### 窗口初始化时状态和动态控制窗口状态的示例
### 分别为 LCL 和 VF
package main
import (
"github.com/energye/energy/v2/cef"
"github.com/energye/golcl/lcl/types"
)
func main() {
//全局初始化 每个应用都必须调用的
cef.GlobalInit(nil, nil)
//创建应用
app := cef.NewApplication()
//指定一个URL地址,或本地html文件目录
cef.BrowserWindow.Config.Url = "https://www.baidu.com"
cef.BrowserWindow.Config.WindowInitState = types.WsFullScreen
cef.BrowserWindow.Config.EnableHideCaption = true
//运行应用
cef.Run(app)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册