U&R: 移除示例下的icon图标文件
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 3.9 KiB |
@ -4,12 +4,11 @@ import (
|
||||
"fmt"
|
||||
"github.com/energye/energy/v2/cef"
|
||||
"github.com/energye/energy/v2/cef/process"
|
||||
"github.com/energye/energy/v2/common"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/types"
|
||||
)
|
||||
|
||||
//主浏览器窗口
|
||||
// 主浏览器窗口
|
||||
func MainBrowserWindow(app *cef.TCEFApplication) {
|
||||
//只有启动主进程才会继续执行
|
||||
if !process.Args.IsMain() {
|
||||
@ -23,11 +22,6 @@ func MainBrowserWindow(app *cef.TCEFApplication) {
|
||||
//窗口宽高
|
||||
cef.BrowserWindow.Config.Width = 1024
|
||||
cef.BrowserWindow.Config.Height = 768
|
||||
if common.IsLinux() && app.IsUIGtk3() {
|
||||
cef.BrowserWindow.Config.IconFS = "resources/icon.png"
|
||||
} else {
|
||||
cef.BrowserWindow.Config.IconFS = "resources/icon.ico"
|
||||
}
|
||||
//chromium配置
|
||||
config := cef.NewChromiumConfig()
|
||||
config.SetEnableMenu(true)
|
||||
@ -69,8 +63,8 @@ func MainBrowserWindow(app *cef.TCEFApplication) {
|
||||
})
|
||||
}
|
||||
|
||||
//控制组件UI
|
||||
//地址栏和控制按钮创建
|
||||
// 控制组件UI
|
||||
// 地址栏和控制按钮创建
|
||||
func controlUI(browserWindow *cef.LCLBrowserWindow) (goBack *lcl.TButton, goForward *lcl.TButton, stop *lcl.TButton, refresh *lcl.TButton, progressLabel *lcl.TLabel, addrBox *lcl.TComboBox) {
|
||||
window := browserWindow
|
||||
//这里使用系统UI组件
|
||||
|
@ -1,10 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"github.com/energye/energy/v2/cef"
|
||||
"github.com/energye/energy/v2/common"
|
||||
"github.com/energye/energy/v2/consts"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"os"
|
||||
@ -12,22 +10,14 @@ import (
|
||||
//_ "net/http/pprof"
|
||||
)
|
||||
|
||||
//go:embed resources
|
||||
var resources embed.FS
|
||||
|
||||
func main() {
|
||||
//全局初始化 每个应用都必须调用的
|
||||
cef.GlobalInit(nil, &resources)
|
||||
cef.GlobalInit(nil, nil)
|
||||
//创建应用
|
||||
var app = cef.NewApplication()
|
||||
//指定一个URL地址,或本地html文件目录
|
||||
cef.BrowserWindow.Config.Url = "https://www.baidu.com"
|
||||
cef.BrowserWindow.Config.Title = "Energy - cookie-manager"
|
||||
if common.IsLinux() && app.IsUIGtk3() {
|
||||
cef.BrowserWindow.Config.IconFS = "resources/icon.png"
|
||||
} else {
|
||||
cef.BrowserWindow.Config.IconFS = "resources/icon.ico"
|
||||
}
|
||||
envPath := os.Getenv("ENERGY_HOME")
|
||||
if envPath == "" {
|
||||
// 未配置 ENERGY_HOME 环境变量, 在当前目录保存cache
|
||||
|
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 3.9 KiB |
@ -7,18 +7,18 @@ import (
|
||||
"github.com/energye/energy/v2/cef"
|
||||
"github.com/energye/energy/v2/cef/ipc"
|
||||
"github.com/energye/energy/v2/cef/ipc/context"
|
||||
"github.com/energye/energy/v2/common"
|
||||
"github.com/energye/energy/v2/consts"
|
||||
"github.com/energye/energy/v2/pkgs/assetserve"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"time"
|
||||
)
|
||||
|
||||
//资源目录,内置到执行程序中
|
||||
// 资源目录,内置到执行程序中
|
||||
//
|
||||
//go:embed resources
|
||||
var resources embed.FS
|
||||
|
||||
//这个示例使用了几个事件来演示下载文件
|
||||
// 这个示例使用了几个事件来演示下载文件
|
||||
func main() {
|
||||
//全局初始化 每个应用都必须调用的
|
||||
cef.GlobalInit(nil, &resources)
|
||||
@ -27,11 +27,6 @@ func main() {
|
||||
//主窗口的配置
|
||||
//指定一个URL地址,或本地html文件目录
|
||||
cef.BrowserWindow.Config.Url = "http://localhost:22022/cookie.html"
|
||||
if common.IsLinux() && cefApp.IsUIGtk3() {
|
||||
cef.BrowserWindow.Config.IconFS = "resources/icon.png"
|
||||
} else {
|
||||
cef.BrowserWindow.Config.IconFS = "resources/icon.ico"
|
||||
}
|
||||
|
||||
//监听获取cookie事件
|
||||
ipc.On("VisitCookie", func(context context.IContext) {
|
||||
|
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 3.9 KiB |
@ -4,7 +4,6 @@ import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"github.com/energye/energy/v2/cef"
|
||||
"github.com/energye/energy/v2/common"
|
||||
"github.com/energye/energy/v2/pkgs/assetserve"
|
||||
)
|
||||
|
||||
@ -15,11 +14,6 @@ func main() {
|
||||
cef.GlobalInit(nil, &resources)
|
||||
app := cef.NewApplication()
|
||||
cef.BrowserWindow.Config.Url = "http://localhost:22022/index.html"
|
||||
if common.IsLinux() && app.IsUIGtk3() {
|
||||
cef.BrowserWindow.Config.IconFS = "resources/icon.png"
|
||||
} else {
|
||||
cef.BrowserWindow.Config.IconFS = "resources/icon.ico"
|
||||
}
|
||||
cef.BrowserWindow.Config.Title = "ENERGY - Custom Drag Window"
|
||||
cef.SetBrowserProcessStartAfterCallback(func(b bool) {
|
||||
fmt.Println("主进程启动 创建一个内置http服务")
|
||||
|
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 3.9 KiB |
@ -1 +1,2 @@
|
||||
无边框可拖拽窗口
|
||||
无边框可拖拽窗口
|
||||
macos
|
29
example/gpu/gpu.go
Normal file
@ -0,0 +1,29 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under Apache License Version 2.0, January 2004
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/energye/energy/v2/cef"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//全局初始化 每个应用都必须调用的
|
||||
cef.GlobalInit(nil, nil)
|
||||
//创建应用
|
||||
app := cef.NewApplication()
|
||||
// 启用GPU加速, 默认 energy 未开启GPU加速
|
||||
// 使用测试网址 www.antutu.com/html5 在任务管理器中观察 CPU 和 GPU 使用情况
|
||||
app.SetEnableGPU(true)
|
||||
cef.BrowserWindow.Config.Url = "https://www.antutu.com/html5"
|
||||
cef.BrowserWindow.Config.Title = "ENERGY GPU Test"
|
||||
//运行应用
|
||||
cef.Run(app)
|
||||
}
|