Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b2a7ab163 |
12
js_export.go
12
js_export.go
@ -8,18 +8,16 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
jsmod.Register("api", map[string]any{
|
jsmod.Register("api", map[string]any{
|
||||||
"call": call,
|
"Call": call,
|
||||||
"setConfig": SetConfig,
|
"SetConfig": SetConfig,
|
||||||
"registerAction": RegisterAction,
|
"RegisterAction": RegisterAction,
|
||||||
"registerSigner": registerSigner,
|
"RegisterSigner": registerSigner,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// call 提供给 JS 的私有入口
|
// call 提供给 JS 的私有入口
|
||||||
func call(ctx context.Context, name string, payload any) (any, error) {
|
func call(ctx context.Context, name string, payload any) (any, error) {
|
||||||
// 注意:在低代码环境中,我们可能需要将 ctx 传入以透传追踪信息给 JS 签名器。
|
// 将 ctx 传入以透传追踪信息给 JS 签名器
|
||||||
// 虽然 api.CallBy[any] 目前不接收 ctx,但底层的 jsRunner 钩子可以从 context 中获取信息。
|
|
||||||
// 如果未来 jsRunner 需要 ctx,我们可以在这里通过 context.WithValue 注入。
|
|
||||||
return CallBy[any](name, payload)
|
return CallBy[any](name, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user