energy/example/load-html-url/load-html-url.go

33 lines
828 B
Go
Raw Normal View History

package main
import (
2023-06-07 16:36:18 +08:00
"embed"
2023-05-31 18:00:34 +08:00
"github.com/energye/energy/v2/cef"
2023-06-07 16:36:18 +08:00
"github.com/energye/energy/v2/common"
"os"
"path"
)
2023-06-07 16:36:18 +08:00
//go:embed resources
var resources embed.FS
func main() {
//全局初始化 每个应用都必须调用的
2023-06-07 16:36:18 +08:00
cef.GlobalInit(nil, &resources)
//创建应用
2023-02-28 18:41:12 +08:00
cefApp := cef.NewApplication()
wd, _ := os.Getwd()
2023-07-07 12:43:42 +08:00
indexHtmlPath := path.Join(wd, "example", "load-html-url", "resources", "index.html")
println("indexHtmlPath", indexHtmlPath)
//指定一个URL地址或本地html文件目录
cef.BrowserWindow.Config.Url = indexHtmlPath
2023-02-03 09:55:45 +08:00
cef.BrowserWindow.Config.Title = "Energy 本地加载html"
if common.IsLinux() && cefApp.IsUIGtk3() {
2023-06-07 16:36:18 +08:00
cef.BrowserWindow.Config.IconFS = "resources/icon.png"
} else {
cef.BrowserWindow.Config.IconFS = "resources/icon.ico"
}
//运行应用
cef.Run(cefApp)
}