mirror of
https://gitee.com/energye/energy.git
synced 2024-11-30 02:37:46 +08:00
U: demo IPC 多窗口通信
This commit is contained in:
parent
1ef8330224
commit
caeb283ace
@ -13,6 +13,7 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
font-family: "Microsoft YaHei UI";
|
||||||
}
|
}
|
||||||
a{
|
a{
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/energye/energy/v2/cef/ipc"
|
"github.com/energye/energy/v2/cef/ipc"
|
||||||
"github.com/energye/energy/v2/cef/ipc/callback"
|
"github.com/energye/energy/v2/cef/ipc/callback"
|
||||||
"github.com/energye/energy/v2/cef/ipc/target"
|
"github.com/energye/energy/v2/cef/ipc/target"
|
||||||
|
"github.com/energye/energy/v2/logger"
|
||||||
"github.com/energye/golcl/lcl"
|
"github.com/energye/golcl/lcl"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -15,14 +16,16 @@ import (
|
|||||||
var assets embed.FS
|
var assets embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
logger.SetEnable(true)
|
||||||
|
logger.SetLevel(logger.CefLog_Debug)
|
||||||
//全局初始化 每个应用都必须调用的
|
//全局初始化 每个应用都必须调用的
|
||||||
cef.GlobalInit(nil, &assets)
|
cef.GlobalInit(nil, &assets)
|
||||||
//创建应用
|
//创建应用
|
||||||
app := cef.NewApplication()
|
app := cef.NewApplication()
|
||||||
app.SetExternalMessagePump(false)
|
//app.SetExternalMessagePump(false)
|
||||||
app.SetMultiThreadedMessageLoop(false)
|
//app.SetMultiThreadedMessageLoop(false)
|
||||||
cef.BrowserWindow.Config.Title = "Energy - ipc multiple-window"
|
cef.BrowserWindow.Config.Title = "Energy - ipc multiple-window"
|
||||||
//cef.BrowserWindow.Config.EnableMainWindow = false
|
cef.BrowserWindow.Config.EnableMainWindow = false
|
||||||
//本地资源加载
|
//本地资源加载
|
||||||
cef.BrowserWindow.Config.LocalResource(cef.LocalLoadConfig{
|
cef.BrowserWindow.Config.LocalResource(cef.LocalLoadConfig{
|
||||||
ResRootDir: "assets",
|
ResRootDir: "assets",
|
||||||
@ -31,7 +34,7 @@ func main() {
|
|||||||
}.Build())
|
}.Build())
|
||||||
|
|
||||||
// 多窗口接收消息
|
// 多窗口接收消息
|
||||||
ipc.On("sendMessage", func(channel callback.IChannel) {
|
ipc.On("sendMessage", func(channel callback.IChannel, type_ int) {
|
||||||
// 获得所有窗口
|
// 获得所有窗口
|
||||||
infos := cef.BrowserWindow.GetWindowInfos()
|
infos := cef.BrowserWindow.GetWindowInfos()
|
||||||
fmt.Println("windows-count:", len(infos))
|
fmt.Println("windows-count:", len(infos))
|
||||||
|
Loading…
Reference in New Issue
Block a user