2023-05-31 17:41:14 +08:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2023-05-31 18:00:34 +08:00
|
|
|
|
"github.com/energye/energy/v2/cef"
|
|
|
|
|
"github.com/energye/energy/v2/cef/process"
|
2023-05-31 17:41:14 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
// 进程类型获取
|
|
|
|
|
// 通过命令行参数 type 区分
|
|
|
|
|
process.Args.Print()
|
|
|
|
|
if process.Args.ProcessType() == process.PT_MAIN {
|
|
|
|
|
// 主进程
|
|
|
|
|
println("main process")
|
|
|
|
|
} else if process.Args.ProcessType() == process.PT_GPU {
|
|
|
|
|
println("gpu process")
|
|
|
|
|
} else if process.Args.ProcessType() == process.PT_UTILITY {
|
|
|
|
|
println("utility process")
|
|
|
|
|
} else if process.Args.ProcessType() == process.PT_RENDERER {
|
|
|
|
|
// 渲染进程
|
|
|
|
|
println("renderer process")
|
|
|
|
|
}
|
|
|
|
|
process.FrameId()
|
|
|
|
|
//全局初始化 每个应用都必须调用的
|
|
|
|
|
cef.GlobalInit(nil, nil)
|
|
|
|
|
//创建应用
|
|
|
|
|
cefApp := cef.NewApplication()
|
|
|
|
|
//指定一个URL地址,或本地html文件目录
|
|
|
|
|
cef.BrowserWindow.Config.Url = "https://energy.yanghy.cn"
|
|
|
|
|
//运行应用
|
|
|
|
|
cef.Run(cefApp)
|
|
|
|
|
}
|