mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 11:47:37 +08:00
upgrade-dev v2.3.25
This commit is contained in:
parent
ab3e7a1435
commit
417bdd3c06
@ -17,11 +17,13 @@ import (
|
||||
|
||||
// appOnContextCreated 创建应用上下文 - 默认实现
|
||||
func appOnContextCreated(browser *ICefBrowser, frame *ICefFrame, context *ICefV8Context) {
|
||||
ipcRender.ipcChannelRender(browser, frame)
|
||||
ipcRender.makeIPC(browser, frame, context)
|
||||
}
|
||||
|
||||
// appMainRunCallback 应用运行 - 默认实现
|
||||
func appMainRunCallback() {
|
||||
ipcBrowser.ipcChannelBrowser()
|
||||
}
|
||||
|
||||
// renderProcessMessageReceived 渲染进程消息 - 默认实现
|
||||
|
29
cef/cef-ipc-browser-channel.go
Normal file
29
cef/cef-ipc-browser-channel.go
Normal file
@ -0,0 +1,29 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under Apache License Version 2.0, January 2004
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
// GO browser IPC通道
|
||||
package cef
|
||||
|
||||
import "github.com/energye/energy/pkgs/channel"
|
||||
|
||||
// browserIPCChan
|
||||
type browserIPCChan struct {
|
||||
ipc channel.IBrowserChannel
|
||||
}
|
||||
|
||||
func (m *ipcBrowserProcess) ipcChannelBrowser() {
|
||||
if m.ipcChannel == nil {
|
||||
m.ipcChannel = new(browserIPCChan)
|
||||
m.ipcChannel.ipc = channel.NewBrowser()
|
||||
m.ipcChannel.ipc.Handler(func(context channel.IIPCContext) {
|
||||
context.Free()
|
||||
})
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@ package cef
|
||||
import (
|
||||
"github.com/energye/energy/consts"
|
||||
"github.com/energye/energy/ipc"
|
||||
"github.com/energye/energy/pkgs/channel"
|
||||
"github.com/energye/energy/pkgs/json"
|
||||
)
|
||||
|
||||
@ -23,16 +22,7 @@ type ipcBrowserProcess struct {
|
||||
ipcObject *ICefV8Value // ipc object
|
||||
emitHandler *ipcEmitHandler // ipc.emit handler
|
||||
onHandler *ipcOnHandler // ipc.on handler
|
||||
ipcChannel channel.IBrowserChannel
|
||||
}
|
||||
|
||||
func (m *ipcBrowserProcess) ipcChannelBrowser() {
|
||||
if m.ipcChannel == nil {
|
||||
m.ipcChannel = channel.NewBrowser()
|
||||
m.ipcChannel.Handler(func(context channel.IIPCContext) {
|
||||
context.Free()
|
||||
})
|
||||
}
|
||||
ipcChannel *browserIPCChan // channel
|
||||
}
|
||||
|
||||
// ipcGoExecuteMethodMessage 执行 Go 监听函数
|
||||
|
33
cef/cef-ipc-render-channel.go
Normal file
33
cef/cef-ipc-render-channel.go
Normal file
@ -0,0 +1,33 @@
|
||||
//----------------------------------------
|
||||
//
|
||||
// Copyright © yanghy. All Rights Reserved.
|
||||
//
|
||||
// Licensed under Apache License Version 2.0, January 2004
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
// GO render IPC通道
|
||||
package cef
|
||||
|
||||
import "github.com/energye/energy/pkgs/channel"
|
||||
|
||||
// renderIPCChan
|
||||
type renderIPCChan struct {
|
||||
browserId int32
|
||||
frameId int64
|
||||
ipc channel.IRenderChannel //channel
|
||||
}
|
||||
|
||||
func (m *ipcRenderProcess) ipcChannelRender(browser *ICefBrowser, frame *ICefFrame) {
|
||||
if m.ipcChannel == nil {
|
||||
m.ipcChannel = new(renderIPCChan)
|
||||
m.ipcChannel.browserId = browser.Identifier()
|
||||
m.ipcChannel.frameId = frame.Identifier()
|
||||
m.ipcChannel.ipc = channel.NewRender(m.ipcChannel.frameId)
|
||||
m.ipcChannel.ipc.Handler(func(context channel.IIPCContext) {
|
||||
context.Free()
|
||||
})
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@ package cef
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/energye/energy/consts"
|
||||
"github.com/energye/energy/pkgs/channel"
|
||||
"github.com/energye/energy/pkgs/json"
|
||||
"time"
|
||||
)
|
||||
@ -25,9 +24,7 @@ type ipcRenderProcess struct {
|
||||
ipcObject *ICefV8Value // ipc object
|
||||
emitHandler *ipcEmitHandler // ipc.emit handler
|
||||
onHandler *ipcOnHandler // ipc.on handler
|
||||
ipcChannel channel.IRenderChannel //channel
|
||||
browserId int32
|
||||
frameId int64
|
||||
ipcChannel *renderIPCChan // channel
|
||||
v8Context *ICefV8Context
|
||||
}
|
||||
|
||||
@ -49,17 +46,6 @@ func (m *ipcRenderProcess) clear() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *ipcRenderProcess) ipcChannelRender(browser *ICefBrowser, frame *ICefFrame) {
|
||||
if m.ipcChannel == nil {
|
||||
m.browserId = browser.Identifier()
|
||||
m.frameId = frame.Identifier()
|
||||
m.ipcChannel = channel.NewRender(m.frameId)
|
||||
m.ipcChannel.Handler(func(context channel.IIPCContext) {
|
||||
context.Free()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (m *ipcRenderProcess) initEventGlobal() {
|
||||
if m.v8Context == nil {
|
||||
m.v8Context = V8ContextRef.Current()
|
||||
|
Loading…
Reference in New Issue
Block a user