Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
bebc4385
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bebc4385
编写于
3月 14, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade-dev v2.3.4
上级
8f083af0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
74 deletion
+72
-74
cef/cef-ipc-render.go
cef/cef-ipc-render.go
+8
-7
cef/cef-types-v8-value.go
cef/cef-types-v8-value.go
+2
-0
example/dev-test/ipc-event/ipc-event.go
example/dev-test/ipc-event/ipc-event.go
+46
-63
example/dev-test/ipc-event/resources/ipc-event.html
example/dev-test/ipc-event/resources/ipc-event.html
+14
-2
ipc/ipc.go
ipc/ipc.go
+2
-2
未找到文件。
cef/cef-ipc-render.go
浏览文件 @
bebc4385
...
...
@@ -114,16 +114,17 @@ func (m *ipcRenderProcess) ipcGoExecuteJSEvent(browser *ICefBrowser, frame *ICef
count
=
args
.
GetData
(
argsBytes
,
0
)
args
.
Free
()
}
if
count
>
0
{
argsV8ValueArray
,
_
=
ipcValueConvert
.
BytesToV8ArrayValue
(
argsBytes
)
}
if
callback
.
context
.
Enter
()
{
callback
.
function
.
ExecuteFunctionWithContext
(
callback
.
context
,
nil
,
argsV8ValueArray
)
if
count
>
0
{
argsV8ValueArray
,
_
=
ipcValueConvert
.
BytesToV8ArrayValue
(
argsBytes
)
}
ret
:=
callback
.
function
.
ExecuteFunctionWithContext
(
callback
.
context
,
nil
,
argsV8ValueArray
)
if
argsV8ValueArray
!=
nil
{
argsV8ValueArray
.
Free
()
}
ret
.
Free
()
callback
.
context
.
Exit
()
}
if
argsV8ValueArray
!=
nil
{
argsV8ValueArray
.
Free
()
}
if
messageId
!=
0
{
// callback
}
...
...
cef/cef-types-v8-value.go
浏览文件 @
bebc4385
...
...
@@ -9,6 +9,8 @@
//----------------------------------------
// CEF v8 value V8所有类型
//
// ICefV8Value 创建和使用一搬在 v8context 上下文中使用
package
cef
import
(
...
...
example/dev-test/ipc-event/ipc-event.go
浏览文件 @
bebc4385
...
...
@@ -42,45 +42,58 @@ func main() {
go
server
.
StartHttpServer
()
})
// 测试用的入参 和 出参
var
r0
=
"字符串{}{}{}字符串[][]字符串"
var
r1
=
1000011
var
r2
=
66666611.0123
var
r3
=
true
var
r4
=
&
MyError
{
error
:
"返回值"
}
var
r5
=
make
([]
string
,
3
,
3
)
r5
[
0
]
=
"Array数组值1"
r5
[
1
]
=
"Array数组值2"
r5
[
2
]
=
"Array数组值3"
var
r6
=
make
([]
*
src
.
StructVarDemo
,
4
,
4
)
r6
[
0
]
=
&
src
.
StructVarDemo
{
StringField
:
"StringField1字符串1"
}
r6
[
1
]
=
&
src
.
StructVarDemo
{
StringField
:
"StringField2字符串2"
,
IntField
:
111
,
BoolField
:
true
,
FloatField
:
999.99
,
SubStructObj
:
&
src
.
SubStructObj
{
StringField
:
"子对象String值"
,
StructVarDemo
:
&
src
.
StructVarDemo
{
StringField
:
"嵌套了嵌套了"
}}}
var
r7
=
make
([]
src
.
StructVarDemo
,
4
,
4
)
r7
[
0
]
=
src
.
StructVarDemo
{
StringField
:
"r7参数字符串1"
}
r7
[
1
]
=
src
.
StructVarDemo
{
StringField
:
"r7参数字符串2"
}
var
r8
=
map
[
string
]
string
{}
r8
[
"r8key1"
]
=
"r8key1"
r8
[
"r8key2"
]
=
"r8key2"
var
r9
=
map
[
string
]
interface
{}{}
r9
[
"r9keyr6"
]
=
r6
r9
[
"r9keyr61"
]
=
r6
[
1
]
r9
[
"r9keyr7"
]
=
r7
[
1
]
r9
[
"r9keystrValue"
]
=
"stringValue"
r9
[
"r9keyintValue"
]
=
50000
r9
[
"r9keyboolValue"
]
=
true
r9
[
"r9keyfloatValue"
]
=
5555555.99999
r9
[
"r9keystrArrr5"
]
=
r5
var
r10
=
make
([]
map
[
string
]
interface
{},
3
)
r10
[
0
]
=
r9
r10
[
1
]
=
r9
r10
[
2
]
=
r9
ipc
.
On
(
"testGoEmit"
,
func
(
context
ipc
.
IContext
)
{
fmt
.
Println
(
"testGoEmit"
,
context
.
BrowserId
(),
context
.
FrameId
())
ipc
.
Emit
(
"onTestName1"
,
"aaa"
,
"bbb"
)
//触发JS监听的函数,并传入参数
ipc
.
Emit
(
"onTestName1"
,
r0
,
r1
,
r2
,
r3
,
r4
,
r5
,
r6
,
r7
,
r8
,
r9
,
r10
)
//ipc.EmitAndCallback("", func() {}, "aaaa")
})
ipc
.
On
(
"testGoEmitAndCallback"
,
func
(
context
ipc
.
IContext
)
{
fmt
.
Println
(
"testGoEmit"
,
context
.
BrowserId
(),
context
.
FrameId
())
//触发JS监听的函数,并传入参数
ipc
.
EmitAndCallback
(
"onTestName1"
,
[]
any
{
r0
,
r1
,
r2
,
r3
,
r4
,
r5
,
r6
,
r7
,
r8
,
r9
,
r10
},
func
()
{
})
//ipc.EmitAndCallback("", func() {}, "aaaa")
})
ipc
.
OnArguments
(
"testResultArgs"
,
func
(
args1
int
)
(
string
,
int
,
float64
,
bool
,
*
MyError
,
[]
string
,
[]
*
src
.
StructVarDemo
,
[]
src
.
StructVarDemo
,
map
[
string
]
string
,
map
[
string
]
interface
{},
[]
map
[
string
]
interface
{})
{
fmt
.
Println
(
"args1"
,
args1
)
var
r0
=
"字符串{}{}{}字符串[][]字符串"
var
r1
=
1000011
var
r2
=
66666611.0123
var
r3
=
true
var
r4
=
&
MyError
{
error
:
"返回值"
}
var
r5
=
make
([]
string
,
3
,
3
)
r5
[
0
]
=
"Array数组值1"
r5
[
1
]
=
"Array数组值2"
r5
[
2
]
=
"Array数组值3"
var
r6
=
make
([]
*
src
.
StructVarDemo
,
4
,
4
)
r6
[
0
]
=
&
src
.
StructVarDemo
{
StringField
:
"StringField1字符串1"
}
r6
[
1
]
=
&
src
.
StructVarDemo
{
StringField
:
"StringField2字符串2"
,
IntField
:
111
,
BoolField
:
true
,
FloatField
:
999.99
,
SubStructObj
:
&
src
.
SubStructObj
{
StringField
:
"子对象String值"
,
StructVarDemo
:
&
src
.
StructVarDemo
{
StringField
:
"嵌套了嵌套了"
}}}
var
r7
=
make
([]
src
.
StructVarDemo
,
4
,
4
)
r7
[
0
]
=
src
.
StructVarDemo
{
StringField
:
"r7参数字符串1"
}
r7
[
1
]
=
src
.
StructVarDemo
{
StringField
:
"r7参数字符串2"
}
var
r8
=
map
[
string
]
string
{}
r8
[
"r8key1"
]
=
"r8key1"
r8
[
"r8key2"
]
=
"r8key2"
var
r9
=
map
[
string
]
interface
{}{}
r9
[
"r9keyr6"
]
=
r6
r9
[
"r9keyr61"
]
=
r6
[
1
]
r9
[
"r9keyr7"
]
=
r7
[
1
]
r9
[
"r9keystrValue"
]
=
"stringValue"
r9
[
"r9keyintValue"
]
=
50000
r9
[
"r9keyboolValue"
]
=
true
r9
[
"r9keyfloatValue"
]
=
5555555.99999
r9
[
"r9keystrArrr5"
]
=
r5
var
r10
=
make
([]
map
[
string
]
interface
{},
3
)
r10
[
0
]
=
r9
r10
[
1
]
=
r9
r10
[
2
]
=
r9
return
r0
,
r1
,
r2
,
r3
,
r4
,
r5
,
r6
,
r7
,
r8
,
r9
,
r10
})
...
...
@@ -106,37 +119,7 @@ func main() {
argument
.
GetByIndex
(
i
)
//fmt.Println(i, "type:", value.Type(), "isInt:", value.IsInt())
}
var
r0
=
"字符串{}{}{}字符串[][]字符串"
var
r1
=
1000011
var
r2
=
66666611.0123
var
r3
=
true
var
r4
=
&
MyError
{
error
:
"返回值"
}
var
r5
=
make
([]
string
,
3
,
3
)
r5
[
0
]
=
"Array数组值1"
r5
[
1
]
=
"Array数组值2"
r5
[
2
]
=
"Array数组值3"
var
r6
=
make
([]
*
src
.
StructVarDemo
,
4
,
4
)
r6
[
0
]
=
&
src
.
StructVarDemo
{
StringField
:
"StringField1字符串1"
}
r6
[
1
]
=
&
src
.
StructVarDemo
{
StringField
:
"StringField2字符串2"
,
IntField
:
111
,
BoolField
:
true
,
FloatField
:
999.99
,
SubStructObj
:
&
src
.
SubStructObj
{
StringField
:
"子对象String值"
,
StructVarDemo
:
&
src
.
StructVarDemo
{
StringField
:
"嵌套了嵌套了"
}}}
var
r7
=
make
([]
src
.
StructVarDemo
,
4
,
4
)
r7
[
0
]
=
src
.
StructVarDemo
{
StringField
:
"r7参数字符串1"
}
r7
[
1
]
=
src
.
StructVarDemo
{
StringField
:
"r7参数字符串2"
}
var
r8
=
map
[
string
]
string
{}
r8
[
"r8key1"
]
=
"r8key1"
r8
[
"r8key2"
]
=
"r8key2"
var
r9
=
map
[
string
]
interface
{}{}
r9
[
"r9keyr6"
]
=
r6
r9
[
"r9keyr61"
]
=
r6
[
1
]
r9
[
"r9keyr7"
]
=
r7
[
1
]
r9
[
"r9keystrValue"
]
=
"stringValue"
r9
[
"r9keyintValue"
]
=
50000
r9
[
"r9keyboolValue"
]
=
true
r9
[
"r9keyfloatValue"
]
=
5555555.99999
r9
[
"r9keystrArrr5"
]
=
r5
var
r10
=
make
([]
map
[
string
]
interface
{},
3
)
r10
[
0
]
=
r9
r10
[
1
]
=
r9
r10
[
2
]
=
r9
context
.
Result
(
r0
,
r1
,
r2
,
r3
,
r4
,
r5
,
r6
,
r7
,
r8
,
r9
,
r10
)
})
...
...
example/dev-test/ipc-event/resources/ipc-event.html
浏览文件 @
bebc4385
...
...
@@ -120,8 +120,20 @@
})
}
ipc
.
on
(
'
onTestName1
'
,
function
(
param1
,
param2
,
param3
)
{
msg
(
"
onTestName1
"
,
param1
,
param2
,
param3
);
ipc
.
on
(
'
onTestName1
'
,
function
(
r0
,
r1
,
r2
,
r3
,
r4
,
r5
,
r6
,
r7
,
r8
,
r9
,
r10
)
{
clearMsg
()
msg
(
"
onTestName1
"
);
msg
(
"
R0:
"
,
r0
);
msg
(
"
R1:
"
,
r1
);
msg
(
"
R2:
"
,
r2
);
msg
(
"
R3:
"
,
r3
);
msg
(
"
R4:
"
,
r4
);
msg
(
"
R5:
"
,
r5
);
msg
(
"
R6:
"
,
r6
,
JSON
.
stringify
(
r6
));
msg
(
"
R7:
"
,
r7
,
JSON
.
stringify
(
r7
));
msg
(
"
R8:
"
,
r8
,
JSON
.
stringify
(
r8
));
msg
(
"
R9:
"
,
r9
,
JSON
.
stringify
(
r9
));
msg
(
"
R10:
"
,
r10
,
JSON
.
stringify
(
r10
));
});
ipc
.
on
(
'
onTestName2
'
,
function
(
param1
,
param2
,
param3
)
{
...
...
ipc/ipc.go
浏览文件 @
bebc4385
...
...
@@ -119,7 +119,7 @@ func Emit(name string, argument ...any) {
//EmitAndCallback
// IPC GO 中触发 JS 监听的事件
func
EmitAndCallback
(
name
string
,
callback
any
,
argument
...
any
)
{
func
EmitAndCallback
(
name
string
,
argument
[]
any
,
callback
any
)
{
if
browser
==
nil
||
name
==
""
||
browser
.
processMessage
==
nil
{
return
}
...
...
@@ -138,7 +138,7 @@ func EmitTarget(name string, target ITarget, argument ...any) {
//EmitTargetAndCallback
// IPC GO 中触发指定目标 JS 监听的事件
func
EmitTargetAndCallback
(
name
string
,
target
ITarget
,
callback
any
,
argument
...
any
)
{
func
EmitTargetAndCallback
(
name
string
,
target
ITarget
,
argument
[]
any
,
callback
any
)
{
if
browser
==
nil
||
name
==
""
||
browser
.
processMessage
==
nil
{
return
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录