|
|
|
|
# 北科工研智慧平台使用说明
|
|
|
|
|
|
|
|
|
|
## 一、后端接口
|
|
|
|
|
|
|
|
|
|
* <u>系统通知</u>
|
|
|
|
|
|
|
|
|
|
> 如果通知需要打开模块,则用户需要对该模块有浏览权限
|
|
|
|
|
> 10秒内会过滤同模块通知请求
|
|
|
|
|
|
|
|
|
|
```http
|
|
|
|
|
//POST /api/trunk/notice/post
|
|
|
|
|
//参数
|
|
|
|
|
{
|
|
|
|
|
mid: string //指定模块id,可在导航管理获得,用户需有权限
|
|
|
|
|
app: string //预留
|
|
|
|
|
title: string //推送标题
|
|
|
|
|
msg: string //推送内容
|
|
|
|
|
showtype: 0|1|2 //0-仅通知 1-通知且提供跳转 2-通知且直接跳转
|
|
|
|
|
filter: { //可选参数,推送过滤
|
|
|
|
|
loginId: string //可选参数,指定接收人
|
|
|
|
|
}
|
|
|
|
|
param: { //可选参数,给模块传递get参数
|
|
|
|
|
//参数名:参数值
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* <u>群发消息</u>
|
|
|
|
|
|
|
|
|
|
> 前端模块需要连接平台websocket服务
|
|
|
|
|
|
|
|
|
|
```http
|
|
|
|
|
//POST /api/trunk/custom/post
|
|
|
|
|
//参数
|
|
|
|
|
{
|
|
|
|
|
data: object, //任意数据
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 二、前端组件
|
|
|
|
|
|
|
|
|
|
- 监听kafka
|
|
|
|
|
|
|
|
|
|
> 前端接收消息的频率会被限制,不适用高频消息处理
|
|
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
import Kafka from "@/components/iBKLinker/comm/kafka"
|
|
|
|
|
|
|
|
|
|
const mq = new Kafka({
|
|
|
|
|
ws: "ws://172.15.199.73:12116",
|
|
|
|
|
onGranted(isGranted) {
|
|
|
|
|
mq.startListen(["SCAN_GUN"]); //授权完毕后,开始监听Topic列表
|
|
|
|
|
},
|
|
|
|
|
onReceive(msg) {
|
|
|
|
|
console.log("receive mq message", msg); //收到消息
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
mq.seconds = 1; //频率限制,秒,最低0.5秒
|
|
|
|
|
mq.start(); //启动ws服务
|
|
|
|
|
|
|
|
|
|
mq.stopListen(["SCAN_GUN"]); //停止监听Topic
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 协同作业
|
|
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
import Cooperation from "@/components/iBKLinker/comm/coop"
|
|
|
|
|
|
|
|
|
|
const cooperate = new Cooperation({
|
|
|
|
|
ws: "ws://172.15.199.73:12116",
|
|
|
|
|
onGranted(isGranted) {
|
|
|
|
|
cooperate.startListen(); //授权完毕后,开始监听,未经授权无法监听
|
|
|
|
|
},
|
|
|
|
|
client: "", //客户端名称,可以设为undefined
|
|
|
|
|
groups: ["Hostmain"], //参与协同分组,可以同时参与多个分组,建议以所在页面为名
|
|
|
|
|
onTrigger: (msg) => {
|
|
|
|
|
//所有消息触发回调,如果设置onTrigger,那么其他次级回调函数将会被忽略
|
|
|
|
|
console.log("cooperation onTrigger", msg)
|
|
|
|
|
},
|
|
|
|
|
onReceive(who, data) {
|
|
|
|
|
//收到协同消息,who:谁发送的,对应配置的client客户端名称,data:数据
|
|
|
|
|
console.log("cooperation onReceive", who, data)
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
cooperate.start(); //启动ws服务
|
|
|
|
|
cooperate.stopListen(); //退出
|
|
|
|
|
cooperate.doc.updated(); //通知群组数据发生更新
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 对应用开放功能
|
|
|
|
|
|
|
|
|
|
> 需要引用@/library/union,针对以单应用、完整连接接入平台的第三方应用
|
|
|
|
|
|
|
|
|
|
1.打开其他模块
|
|
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
let app = new ControlledFrameRuntime()
|
|
|
|
|
app.openPage(moduleId, true, {
|
|
|
|
|
name: "Longe", age: 20, male: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
//moduleId:模块id,在模块配置注册后的id,登录账号需有访问权限
|
|
|
|
|
//是否打开新页面
|
|
|
|
|
//传递参数
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2.系统提醒
|
|
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
let app = new ControlledFrameRuntime()
|
|
|
|
|
app.systemWarn(moduleId, title, msg)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
3.重新登录
|
|
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
let app = new ControlledFrameRuntime()
|
|
|
|
|
app.doLogin()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
4.监听主题变更事件
|
|
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
let app = new ControlledFrameRuntime()
|
|
|
|
|
app.onChangeTheme((theme) => {
|
|
|
|
|
//do something
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 三、系统设置
|
|
|
|
|
|
|
|
|
|
* 调试模式
|
|
|
|
|
|
|
|
|
|
> 进入系统后,连续点击底部栏右侧 **<mark>Powered By iBKLinker</mark>** 6次
|
|
|
|
|
|
|
|
|
|
| 名称 | 功能 |
|
|
|
|
|
| -------------------------------- | --------- |
|
|
|
|
|
| 本地地址 | 本地调试地址 |
|
|
|
|
|
| 启用状态 | 启动、禁用调试模式 |
|
|
|
|
|
| 展示区域 | 框架外部、内部展示 |
|
|
|
|
|
|
|
|
|
|
> 外部:打开需要调试的模块,右键Tab标签,新开浏览器
|
|
|
|
|
> 内部:点击目录,将会直接在框架内容区打开,其他模块会存在页面404的情况
|
|
|
|
|
|
|
|
|
|
* 模块属性
|
|
|
|
|
|
|
|
|
|
> 配置在:系统任务-模块管理
|
|
|
|
|
|
|
|
|
|
| 名称 | 功能 |
|
|
|
|
|
| --- | ------------------------- |
|
|
|
|
|
| 固定 | 固定必须 |
|
|
|
|
|
| 全屏 | 打开后进入浏览器全屏。同时为首屏时无效 |
|
|
|
|
|
| 外链 | 点击目录,在新浏览器窗口打开外部链接 |
|
|
|
|
|
| 隐藏 | 目录中隐藏,但是可被代码打开 |
|
|
|
|
|
| 公共 | 无需权限的公共模块(预留) |
|
|
|
|
|
| 首屏 | 登录系统后首屏界面,多个首屏时,将会打开序号靠前的 |
|