easinote-proxy
v0.1.10-beta.0
Published
外部业务不用关心当前的页面是在 windows 客户端运行还是在 web 内嵌的 iframe 运行,直接调用此项目提供的 API,即可完成相关的功能。
Downloads
4
Keywords
Readme
希沃白板前端 API proxy
外部业务不用关心当前的页面是在 windows 客户端运行还是在 web 内嵌的 iframe 运行,直接调用此项目提供的 API,即可完成相关的功能。
使用说明
在调用相关 API 之前,需要先进行初始化。
以React为例,两种方式。
- 方式一:可以在程序的入口处初始化
import EasiNoteProxy from 'easinote-proxy';
EasiNoteProxy.init().then(()=> ReactDom.render("xxx", "xx"));
- 方式二:在组件的生命周期中初始化
componentWillMount/ComponentDidMount(){
await EasiNoteProxy.init()
}
API 调用方式如下,具体的 API,见下方的详细说明。
EasiNoteProxy.Proxy.XXX('xxx');
元素插件相关 API
1 插入多媒体
EasiNoteProxy.Proxy.insertMedia("{多媒体数据描述的 Json 对象}");
{
"type": "video",
"url": "http://vfx.mtime.cn/Video/2019/03/19/mp4/190319212559089721.mp4",
"fileName": "测试.mp4",
}
详见:http://open.seewo.com/#/service/1847/doc/2262
2 插入web内容卡片元素
EasiNoteProxy.Proxy.insertElementByJson('WebPresentationCard2','{元素数据描述的 Json 对象}');
详见:http://open.seewo.com/#/service/1847/doc/2263
3 插入图片可折叠卡片元素
EasiNoteProxy.Proxy.insertElementByJson('ImageFoldCard','{元素数据描述的 Json 对象}');
详见:http://open.seewo.com/#/service/1847/doc/2264
4 同步调用客户端方法
方法名:invokeAsync 参数:params: obj
params 是一个对象,对象包含的字段如下:
name: string 需要调用的客户端方法
args: Array 客户端该方法需要的参数
例子
// 调用OpenHyperlink(客户端中打开外链)
import EasiNoteProxy from 'easinote-proxy';
EasiNoteProxy.Proxy.invokeAsync({
name: 'OpenHyperlink',
args: ['https://baidu.com']
})
如果需要拿返回值
// 调用GetUserAgent(获取客户端信息)
import EasiNoteProxy from 'easinote-proxy';
const userAgent = await EasiNoteProxy.Proxy.invokeAsync({
name: 'GetUserAgent'
})
建立子页面(iframe)与父页面的通信关系
三方资源 web 页场景