You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DayeRdms_platform-code/platform-code/plat-helper.md

157 lines
4.6 KiB
Markdown

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 北科工研智慧平台使用说明
## 一、后端接口
* <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的情况
* 模块属性
> 配置在:系统任务-模块管理
| 名称 | 功能 |
| --- | ------------------------- |
| 固定 | 固定必须 |
| 全屏 | 打开后进入浏览器全屏。同时为首屏时无效 |
| 外链 | 点击目录,在新浏览器窗口打开外部链接 |
| 隐藏 | 目录中隐藏,但是可被代码打开 |
| 公共 | 无需权限的公共模块(预留) |
| 首屏 | 登录系统后首屏界面,多个首屏时,将会打开序号靠前的 |