2023-02-03 09:01:29 +08:00
|
|
|
|
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"
|
2023-02-03 09:01:29 +08:00
|
|
|
|
"os"
|
|
|
|
|
"path"
|
|
|
|
|
)
|
|
|
|
|
|
2023-06-07 16:36:18 +08:00
|
|
|
|
//go:embed resources
|
|
|
|
|
var resources embed.FS
|
|
|
|
|
|
2023-02-03 09:01:29 +08:00
|
|
|
|
func main() {
|
|
|
|
|
//全局初始化 每个应用都必须调用的
|
2023-06-07 16:36:18 +08:00
|
|
|
|
cef.GlobalInit(nil, &resources)
|
2023-02-03 09:01:29 +08:00
|
|
|
|
//创建应用
|
2023-02-28 18:41:12 +08:00
|
|
|
|
cefApp := cef.NewApplication()
|
2023-02-03 09:01:29 +08:00
|
|
|
|
wd, _ := os.Getwd()
|
2023-07-07 12:43:42 +08:00
|
|
|
|
indexHtmlPath := path.Join(wd, "example", "load-html-url", "resources", "index.html")
|
2023-02-03 12:48:55 +08:00
|
|
|
|
println("indexHtmlPath", indexHtmlPath)
|
2023-02-03 09:01:29 +08:00
|
|
|
|
//指定一个URL地址,或本地html文件目录
|
|
|
|
|
cef.BrowserWindow.Config.Url = indexHtmlPath
|
2023-02-03 09:55:45 +08:00
|
|
|
|
cef.BrowserWindow.Config.Title = "Energy 本地加载html"
|
2023-07-20 18:04:23 +08:00
|
|
|
|
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"
|
|
|
|
|
}
|
2023-02-03 09:01:29 +08:00
|
|
|
|
//运行应用
|
|
|
|
|
cef.Run(cefApp)
|
|
|
|
|
}
|