energy/example/process-type/process-type.go

39 lines
1.0 KiB
Go
Raw Normal View History

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-06-07 16:36:18 +08:00
"github.com/energye/energy/v2/common"
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"
2023-06-07 16:36:18 +08:00
if common.IsLinux() {
cef.BrowserWindow.Config.IconFS = "resources/icon.png"
} else {
cef.BrowserWindow.Config.IconFS = "resources/icon.ico"
}
2023-05-31 17:41:14 +08:00
//运行应用
cef.Run(cefApp)
}