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

39 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"github.com/energye/energy/v2/cef"
"github.com/energye/energy/v2/cef/process"
"github.com/energye/energy/v2/common"
)
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"
if common.IsLinux() && cefApp.IsUIGtk3() {
cef.BrowserWindow.Config.IconFS = "resources/icon.png"
} else {
cef.BrowserWindow.Config.IconFS = "resources/icon.ico"
}
//运行应用
cef.Run(cefApp)
}