@envision-digital/enos-app-portal-sdk
v0.1.12
Published
App portal SDK
Downloads
4
Readme
ENOS-APP-PORTAL 前端 SDK
Installation
前端 SDK 基于 NPM,安装方式如下
yarn add enos-app-portal-sdk
或者
npm install enos-app-portal-sdk
渲染规则
如果在中文环境下选择进入 appId 为 ”“, menuCode 为 ""的应用,并且 state 为""的应用菜单,内容 window location 为:
https:<domain>/<配置的menu-URL>?appId=<appId>&menuCode=<menuCode>&categoryId=<categoryId>&state=<state>&locale=zh-CN
其中:categoryId 指的是应用所在的分类的 id,比如光伏为 22
API
框架本身提供 API,供内部 App 调用,主要用于用户信息获取和页面操作等
需要引入 SDK 模块。 此 SDK 时基于单向的 window 之间 Postmessage 和 Promise 搭建的 Iframe 之间双向数据通道,所以,所有 API 均返回Promise
。
import appPortalSDK from 'enos-app-portal-sdk';
1.getUserInfo
获取当前用户信息
调用示例
appPortalSDK.getUserInfo()
返回示例
{
"accessToken": "APP_PORTAL_S_zv7dFSHmevr6Xs64fGKm4MbKSRe79qeW",
"createdTime": "2019-05-14 08:38:31.0",
"company": "",
"department": "",
"description": "test",
"domain": "",
"email": "[email protected]",
"id": "u15578231118721",
"isInitPassword": false,
"name": "portal_test01",
"nickName": "quququ",
"organization": {
"id": "o15578227985571",
"name": "portal_test01"
},
"phone": "123232323",
"phoneArea": "",
"position": "",
"theme": "DARK"
}
2.getAppInfo
获取应用信息
调用示例, 调用当前应用信息
appPortalSDK.getAppInfo()
返回示例
{
"category": {
"id": 21,
"name": "Wind"
},
"code": "Wind",
"createdTime": "2019-05-14 08:38:31.0",
"createdType": null,
"description": "Wind",
"descriptionJson": {
"default": "wind",
"en_US": "wind",
"es_ES": "wind",
"ja_JP": "wind",
"zh_CN": "wind"
},
"id": "123",
"isDisplay": true,
"isEnable": true,
"isNewNavigation": true,
"isShortcut": true,
"menus": [
{
"additionType": 0,
"children": [
{
"additionType": 0,
"children": null,
"code": "view",
"createdTime": "2019-05-14 08:38:31.0",
"displayOrder": 12,
"icon": "icon-web1",
"id": "ut incididunt ex",
"jumpLocation": null,
"name": "ullamco veniam",
"nameJson": {
"default": "ullamco veniam",
"en_US": "ullamco veniam",
"es_ES": "ullamco veniam",
"ja_JP": "ullamco veniam",
"zh_CN": "ullamco veniam"
},
"parentId": "24cb078c-a119-4fa9-aad8-7f161a2b53f2",
"sourceApp": null,
"url": "laborum aute minim mollit laboris"
}
],
"code": "wyfMenu1",
"createdTime": "2019-05-14 08:38:31.0",
"displayOrder": 1,
"icon": "icon-instance1",
"id": "24cb078c-a119-4fa9-aad8-7f161a2b53f2",
"jumpLocation": null,
"name": "wyfMenu1",
"nameJson": {
"default": "wyfMenu1",
"en_US": "wyfMenu1",
"es_ES": "wyfMenu1",
"ja_JP": "wyfMenu1",
"zh_CN": "wyfMenu1"
},
"parentId": "",
"sourceApp": null,
"url": "/xxxxx/"
}
],
"name": "wind",
"nameJson": {
"default": "wind",
"en_US": "wind",
"es_ES": "wind",
"ja_JP": "wind",
"zh_CN": "wind"
},
"order": 0,
"permissions": [
{
"additionType": null,
"children": null,
"code": "adipisicing",
"createdTime": "2019-05-14 08:38:31.0",
"displayOrder": 1,
"icon": null,
"id": "cillu",
"jumpLocation": null,
"name": "magna",
"nameJson": {
"default": "magna",
"en_US": "magna",
"es_ES": "magna",
"ja_JP": "magna",
"zh_CN": "magna"
},
"parentId": "",
"sourceApp": null,
"url": ""
}
],
"sourceApp": null,
"status": true,
"structures": null,
"type": null,
"url": null
}
3.getAppAssets
返回当前 app 对应的资产树
调用示例
appPortalSDK.getAppAssets(); // 不包含关联资源
appPortalSDK.getAppAssets(true); // 包含关联资源
appPortalSDK.getAppAssets(false, ['all']); // 指定返回的资源类型,缺省时默认值为['auth_unit', 'logic_unit'],可按ou配置
返回示例
{
"associatedResources": [], // 关联资源
"children": [
{
"associatedResources": [], // 关联资源
"children": [
{
"associatedResources": [], // 关联资源
"children": [],
"displayOrder": 0,
"id": "a112233",
"name": "node-1-1",
"nameJson": {
"default": "node-1-1",
"en_US": "node-1-1",
"es_ES": "node-1-1",
"ja_JP": "node-1-1",
"zh_CN": "node-1-1"
},
"parentId": "",
"tag": null,
"tags": []
}
],
"displayOrder": 0,
"id": "a1122",
"name": "tree-node-1",
"nameJson": {
"default": "tree-node-1",
"en_US": "tree-node-1",
"es_ES": "tree-node-1",
"ja_JP": "tree-node-1",
"zh_CN": "tree-node-1"
},
"parentId": "",
"tag": "auth-unit",
"tags": []
}
],
"displayOrder": 0,
"id": "a11",
"name": "asset-tree",
"nameJson": {
"default": "asset-tree",
"en_US": "asset-tree",
"es_ES": "asset-tree",
"ja_JP": "asset-tree",
"zh_CN": "asset-tree"
},
"parentId": "",
"tag": null,
"tags": [
{
"id": "xnka",
"key": "name",
"structureId": "aefas",
"value": "auiqknd"
}
]
}
4.getLocale
获取当前语言信息
调用示例
appPortalSDK.getLocale();
‘en-US’ // 'zh-CN'
5.switchPage
APP 跳转页面
调用示例
appPortalSDK.switchPage({
appId: xxx,
appCode: xxxx, //开发者注册应用时,所填写的应用唯一标识符, appId 和 appCode 二选一, appCode优先级高于appI
menuCode: xxx,
openOnNewTab: false, // 是否在新窗口打开菜单
state:xxx, // 会在绘制ifreame的时候加入url的query中
addToVisitRecord: false, // 是否添加到最近访问记录
viewMode: 2 // 大屏模式,隐藏菜单和顶部导航
})
返回示例
true
6.setNotificationUrl
设置消息窗口
调用示例
appPortalSDK.setNotificationUrl(’https://xxx.xxx/ss.html‘)
返回示例
true
7.setHelpUrl
设置帮助信息
调用示例
appPortalSDK.setHelpUrl('https://xxx.xxx/ss.html');
返回示例
true
8.logout
调用示例
appPortalSDK.logout();
9.设置显示模式
setViewMode()
调用示例
appPortalSDK.setViewMode(0); // 默认模式,菜单和顶部导航都显示
appPortalSDK.setViewMode(1); // 隐藏菜单模式,不可点击显示菜单
appPortalSDK.setViewMode(2); // 大屏模式,隐藏菜单和顶部导航
appPortalSDK.setViewMode(3); // 隐藏菜单模式,可点击显示菜单
appPortalSDK.setViewMode(4); // 隐藏顶部导航
10. 显示/隐藏菜单(保留用户可点击按钮)
调用示例
appPortalSDK.toggleMenu(boolean); // true / false
11.打开外部链接
openLink(link)
12.获取当前支持的语言列表
getAvailableLocales()
13. 获取当前主题
getTheme()
14.getStructureByApp
返回用户在当前app内的可见组织结构列表
调用示例
appPortalSDK.getStructureByApp();
返回示例
[
{
"id": "a1232-123123123",
"parentId": "",
"name": "asset-1",
"displayOrder": 0,
"description": "ajkxnamedyh"
"tags": {
"key1": "value1"
}
}
]
15.getStructureByDetail
返回可见组织结构的资产详情, 与getStructureByApp搭配使用可用于切换资产树
调用示例
appPortalSDK.getStructureByDetail(structureRootId); // 不包含关联资源
appPortalSDK.getStructureByDetail(structureRootId, true); // 包含关联资源
返回示例
同3.getAppAssets
16.setBeforeLeave
设置页面离开前二次确认弹窗信息
调用示例
appPortalSDK.setBeforeLeave(true, 'xxxxxx'); // 页面离开前需要二次确认弹窗,弹窗自定义提示信息“xxxxxx”
appPortalSDK.setBeforeLeave(false); // 页面离开前不需要二次确认弹窗(默认状态)
17.useDrawer
唤起App Portal抽屉
调用示例
appPortalSDK.useDrawer(urlData, componentData);
urlData = {
url: 'xxxx', // 抽屉内部打开的页面地址
openNewUrl: 'xxxxxxxxxx' // 点击新页面打开按钮时在浏览器新页面打开的页面地址
}
componentData = {
placement: 'right', // 'bottom'/'right', 默认bottom
title: 'title',
subTitle: 'subTitle',
width: '60%', // placement='right'时设置有效, 默认'70%'
height: '60%', // placement='bottom'时设置有效, 默认'80%'
showNewOpen: false, // 是否展示新页面打开按钮, 默认true
theme: 'WHITE', // 'DARK'/'WHITE', 默认为App Portal当前主题色
maskClosable: 'true', // 点击遮罩层时抽屉是否可关闭, 默认false
destroyOnClose: 'false' // 关闭时是否销毁抽屉内部子元素, 默认true
}
关闭App Portal抽屉
调用示例
appPortalSDK.useDrawer();
18.useModal
唤起App Portal弹窗
调用示例
appPortalSDK.useModal(urlData, componentData, type = 1);
urlData = {
url: 'xxxx', // 弹窗内部打开页面地址
}
componentData = {
title: 'title',
size: 'large', // 'small'/'medium'/'large', 弹窗大小, 用于设置宽度, 默认medium
height: 340, // 弹窗内容高度, 设置后弹窗高度范围为200px-600px, 若超出或不足弹窗高度范围, 按极值展示
theme: 'WHITE', // 'DARK'/'WHITE', 默认为App Portal当前主题色
maskClosable: 'true', // 点击遮罩层时弹窗是否可关闭, 默认false
destroyOnClose: 'false' // 关闭时是否销毁弹窗内部子元素, 默认true
}
type = 1 / 2 // 1代表普通弹窗,2代表二次确认弹窗
关闭App Portal弹窗
调用示例
appPortalSDK.useModal();
19.showMessage
展示接口调用的提示信息
调用示例
appPortalSDK.showMessage(type = 'success', 'message'); // type = 'success'/'failed'/'warning'
20.setConfig
开启lite模式
调用示例
appPortalSDK.setConfig({
appId: 'abcd', // 必须
liteMode: true, // 必须
token: 'efgh' // 可选,不传时会从localStorage中取值,key值与原sdk保持一致
});
21.getVisitRecords
获取最近访问记录
调用示例
appPortalSDK.getVisitRecords()
返回示例
[
{
"appId": "abcd"
"menuCode": "menu21"
"menuName": "menu21"
"url": "defg"
}
]
22.useWindow
唤起App Portal悬浮窗口
调用示例
appPortalSDK.useWindow(winConfig);
winConfig = {
code: 'xxxx', // 悬浮窗口组件标识码,必填
url: 'xxxx', // 悬浮窗口内部打开页面地址
width: 480,
height: 320,
top: 50,
right: 20,
bottom: 50, // 和top一同配置时取top值
left: 20, // 和right一同配置时取left值
autoDestroy: false, // 页面跳转时自动销毁浮动窗口,默认true
mask: true, // 是否需要遮罩层, 默认false
visible: true, // 显示悬浮窗口组件, 默认false
undisturbed: true, // 是否需要免打扰提示, 默认true
undisturbedAfterTimes: 2 // 触发免打扰需要的次数, 默认3
}
关闭App Portal悬浮窗口
调用示例
appPortalSDK.useWindow({code: 'xxxx'});
获取App Portal悬浮窗口数据
调用示例
appPortalSDK.getWindowData({code: 'xxx', incrementalUpdate: true}); // 增量数据
appPortalSDK.getWindowData({code: 'xxx'}); // 全部数据
23.setLocale
设置语言
调用示例
appPortalSDK.setLocale('en-US');
版本依赖
SDK版本 | app portal版本 ---------|---------- 0.1.12 | >=2.4.6-r-2 0.1.11 | >=2.4.6-r-1 0.1.10 | >=2.4.9 0.1.7 | >=2.4.8 0.1.6 | >=2.4.7 0.1.1 | >=2.4.4 0.0.16 | >=2.3.14 0.0.15 | >=2.3.10
Release Notes:
v0.1.12
- 增加useWindow和getWindowData方法。
- 增加一种新的显示模式,viewMode值对应是4。
- 增加setLocale方法。
v0.1.11
- switchPage方法增加viewMode参数,支持切换页面时指定显示模式。
- 增加一种新的显示模式,viewMode值对应是3。
v0.1.10
- getAppAssets方法增加参数可指定返回的资源类型。缺省时默认值为['auth_unit', 'logic_unit'],可按ou配置,传['all']代表需要全部类型。
v0.1.9
- 更新readme。
v0.1.8
- 修复跨域错误。
v0.1.7
- lite版getUserInfo方法增加邮箱RSA解密。
- 修改getAppAssets和getStructureByDetail方法调用示例。
- 增加getVisitRecords方法用以获取新版导航下最近访问记录。
v0.1.6
- getAppAssets和getStructureByDetail方法增加参数可请求关联资源,默认值为false不请求关联资源。
v0.1.5
- 修复lite模式token丢失问题。
v0.1.4
- 修复lite版getAppAssets方法在重复调用时报promise方法错误拿不到数据问题。
- 更新readme,补充开启lite模式示例。
v0.1.3
- 修复因v0.1.1内部传参方式变化引起的getStructureByDetail、setBeforeLeave、setHelpUrl、setNotificationUrl、setPageTitle、setViewMode、showMessage、toggleMenu、useDrawer、useModal和switchPage方法失效问题。
- 增加lite版本,开启后在App Portal同域下可由sdk直接请求接口获取对应数据。lite版支持的方法有getAppAssets、getAppInfo、getAvailableLocales、getLocale、getStructureByApp、getStructureByDetail、getTheme、getUserInfo和openLink。
v0.1.2
- 更新getUserInfo、getAppInfo和getAppAssets方法返回示例。
v0.1.1
- switchPage方法增加入参addToVisitRecord,用于决定切换页是否需要添加到最近访问记录中
- 优化通信方式,当应用与app portal不跨域时直接获取挂载在window上的数据
v0.0.17
- 修复当存在多层app portal时,无法获取到期望app portal的数据的bug
V0.0.16
- add useDrawer function and useModal function
- add showMessage function
V0.0.15
- add getStructureByApp function and getStructureByDetail function
- add setBeforeLeave function
V0.0.14
- 添加兼容性处理
- 此版本建议配合 GA2.2.0版本App Portal 使用
V0.0.13
- add getTheme function
v0.0.11
- add getAvailableLocales function
- remove 404 check
v0.0.9
- 当app portal 不是顶层window的时候,没法接受信息bug
- 修改随机数规则,防止同一个Promise.all 调用多次相同方法key一致的问题
v0.0.5
- 增加
switchPage
在新窗口打开菜单选项 - 添加
openLink
选项
V0.0.4
- 页面跳转支持通过应用CODE跳转
V0.0.3
- 增加 toggleMenu 接口
v0.0.2
- 混淆压缩代码
- 添加检验机制,检验是否在 APP-PORTAL 中使用,如果不是理解 reject
- 代码结构调整
v0.0.
- 提供基于 ES5 的 SDK Module
- 新增大屏全屏模式接口
- 改变菜单 URL 配置规则,可配置相对路径
- 渲染添加 appId,menuCode, categoryId,locale 参与在内容 query 中
- 优化加载和调用速度
- 修改 readme 信息
=========================
ENOS-APP-PORTAL Frontend SDK
Installation
Front end SDK is based on NPM, and the installation method is as follows:
yarn add enos-app-portal-sdk
OR
npm install enos-app-portal-sdk
Rendering rules
If you are using a Chinese environment, appId refers to the "", menuCode refers to the "" application, state refers to the "" application menu, and the content window URL is:
https:<domain>/<configured menu-URL>? appId=<appId>&menuCode=<menuCode>&categoryId=<categoryId>&state=<state>&locale=zh-CN
Note: categoryId refers to the ID of the category of the application ID. For example, the category ID for solar is 22.
API
The framework itself provides APIs that can be called by internal apps. They are mainly used for user information acquisition or page operations.
You need to connect the SDK module. This development tool will create a promised data channel which is based on the postmessage
API and ES6 promise.
import appPortalSDK from 'enos-app-portal-sdk';
1.getUserInfo
Acquire current user's information
Call example
appPortalSDK.getUserInfo()
Return example
{
"accessToken": "APP_PORTAL_S_zv7dFSHmevr6Xs64fGKm4MbKSRe79qeW",
"createdTime": "2019-05-14 08:38:31.0",
"company": "",
"department": "",
"description": "test",
"domain": "",
"email": "[email protected]",
"id": "u15578231118721",
"isInitPassword": false,
"name": "portal_test01",
"nickName": "quququ",
"organization": {
"id": "o15578227985571",
"name": "portal_test01"
},
"phone": "123232323",
"phoneArea": "",
"position": "",
"theme": "DARK"
}
2.getAppInfo
Acquire app information
Call example, where the current app's information is called
appPortalSDK.getAppInfo()
Return example
{
"category": {
"id": 21,
"name": "Wind"
},
"code": "Wind",
"createdTime": "2019-05-14 08:38:31.0",
"createdType": null,
"description": "Wind",
"descriptionJson": {
"default": "wind",
"en_US": "wind",
"es_ES": "wind",
"ja_JP": "wind",
"zh_CN": "wind"
},
"id": "123",
"isDisplay": true,
"isEnable": true,
"isNewNavigation": true,
"isShortcut": true,
"menus": [
{
"additionType": 0,
"children": [
{
"additionType": 0,
"children": null,
"code": "view",
"createdTime": "2019-05-14 08:38:31.0",
"displayOrder": 12,
"icon": "icon-web1",
"id": "ut incididunt ex",
"jumpLocation": null,
"name": "ullamco veniam",
"nameJson": {
"default": "ullamco veniam",
"en_US": "ullamco veniam",
"es_ES": "ullamco veniam",
"ja_JP": "ullamco veniam",
"zh_CN": "ullamco veniam"
},
"parentId": "24cb078c-a119-4fa9-aad8-7f161a2b53f2",
"sourceApp": null,
"url": "laborum aute minim mollit laboris"
}
],
"code": "wyfMenu1",
"createdTime": "2019-05-14 08:38:31.0",
"displayOrder": 1,
"icon": "icon-instance1",
"id": "24cb078c-a119-4fa9-aad8-7f161a2b53f2",
"jumpLocation": null,
"name": "wyfMenu1",
"nameJson": {
"default": "wyfMenu1",
"en_US": "wyfMenu1",
"es_ES": "wyfMenu1",
"ja_JP": "wyfMenu1",
"zh_CN": "wyfMenu1"
},
"parentId": "",
"sourceApp": null,
"url": "/xxxxx/"
}
],
"name": "wind",
"nameJson": {
"default": "wind",
"en_US": "wind",
"es_ES": "wind",
"ja_JP": "wind",
"zh_CN": "wind"
},
"order": 0,
"permissions": [
{
"additionType": null,
"children": null,
"code": "adipisicing",
"createdTime": "2019-05-14 08:38:31.0",
"displayOrder": 1,
"icon": null,
"id": "cillu",
"jumpLocation": null,
"name": "magna",
"nameJson": {
"default": "magna",
"en_US": "magna",
"es_ES": "magna",
"ja_JP": "magna",
"zh_CN": "magna"
},
"parentId": "",
"sourceApp": null,
"url": ""
}
],
"sourceApp": null,
"status": true,
"structures": null,
"type": null,
"url": null
}
3.getAppAssets
Return the asset tree of the current app
Call example
appPortalSDK.getAppAssets(); // Declude Associate Resource
appPortalSDK.getAppAssets(true); // Include Associate Resource
appPortalSDK.getAppAssets(false, ['all']); // Specify the resource type to return. The default value is ['auth_unit', 'logic_unit'], which can be configured by ou
Return example
{
"associatedResources": [], // Associate Resource
"children": [
{
"associatedResources": [], // Associate Resource
"children": [
{
"associatedResources": [], // Associate Resource
"children": [],
"displayOrder": 0,
"id": "a112233",
"name": "node-1-1",
"nameJson": {
"default": "node-1-1",
"en_US": "node-1-1",
"es_ES": "node-1-1",
"ja_JP": "node-1-1",
"zh_CN": "node-1-1"
},
"parentId": "",
"tag": null,
"tags": []
}
],
"displayOrder": 0,
"id": "a1122",
"name": "tree-node-1",
"nameJson": {
"default": "tree-node-1",
"en_US": "tree-node-1",
"es_ES": "tree-node-1",
"ja_JP": "tree-node-1",
"zh_CN": "tree-node-1"
},
"parentId": "",
"tag": "auth-unit",
"tags": []
}
],
"displayOrder": 0,
"id": "a11",
"name": "asset-tree",
"nameJson": {
"default": "asset-tree",
"en_US": "asset-tree",
"es_ES": "asset-tree",
"ja_JP": "asset-tree",
"zh_CN": "asset-tree"
},
"parentId": "",
"tag": null,
"tags": [
{
"id": "xnka",
"key": "name",
"structureId": "aefas",
"value": "auiqknd"
}
]
}
4.getLocale
Acquire the current language information
Call example
appPortalSDK.getLocale();
‘en-US’ // 'zh-CN'
5.switchPage
Switch app pages
Call example
appPortalSDK.switchPage({
appId: xxx,
appCode: xxxx, //When a developer registers an app, he/she needs to enter either the appId or the appCode. appCode takes precedence over appId.
menuCode: xxx,
openOnNewTab: false, //Whether to open the page on a new tab
state: xxx, // To be added to the URL query when rendering iframe
addToVisitRecord: false, // Whether to add to recent visited records
viewMode: 2 // This mode hides the menu and the top navigation bar. It is suitable for display on big screens.
})
Return example
true
6.setNotificationUrl
Set the notification URL
Call example
appPortalSDK.setNotificationUrl(’https://xxx.xxx/ss.html‘)
Return example
true
7.setHelpUrl
Set the Help URL
Call example
appPortalSDK.setHelpUrl('https://xxx.xxx/ss.html');
Return example
true
8.logout
Call example
appPortalSDK.logout();
9. Set the view mode
setViewMode()
Call example
appPortalSDK.setViewMode(0); // The default mode. This mode displays the menu and the top navigation bar.
appPortalSDK.setViewMode(1); // This mode hides the menu, cannot be clicked to display menu.
appPortalSDK.setViewMode(2); // This mode hides the menu and the top navigation bar. It is suitable for display on big screens.
appPortalSDK.setViewMode(3); // This mode hides the menu, can be clicked to display menu.
appPortalSDK.setViewMode(4); // Hide top navigation bar.
10. Show/hide the menu (retaining buttons that users can click)
Call example
appPortalSDK.toggleMenu(boolean); // true / false
11. Open external links
openLink(link)
12.get Available Locales
getAvailableLocales()
13. get current theme
getTheme()
14.getStructureByApp
Return the visible organization structure list of the current user by app
Call example
appPortalSDK.getStructureByApp();
Return example
[
{
"id": "a1232-123123123",
"parentId": "",
"name": "asset-1",
"displayOrder": 0,
"description": "ajkxnamedyh"
"tags": {
"key1": "value1"
}
}
]
15.getStructureByDetail
Return the asset details for the visible organization structure. Can be used with getStructureByApp to switch asset trees.
Call example
appPortalSDK.getStructureByDetail(structureRootId); // Declude Associate Resource
appPortalSDK.getStructureByDetail(structureRootId, true); // Include Associate Resource
Return example
Same as 3.getAppAssets
16.setBeforeLeave
Set the information of the second confirmation modal before leaving the page
Call example
appPortalSDK.setBeforeLeave(true, 'xxxxxx'); // Before leaving the page, need show a modal to confirm whether to leave, and the custom prompt message is "xxxxxx"
appPortalSDK.setBeforeLeave(false); // Not show the confirmation modal before leaving the page(default state)
17.useDrawer
Raise App Portal Drawer
Call example
appPortalSDK.useDrawer(urlData, componentData);
urlData = {
url: 'xxxx', // The URL of the page opened inside the drawer
openNewUrl: 'xxxxxxxxxx' // The URL of the page opened in the new page of the browser when the newOpen button is clicked
}
componentData = {
placement: 'right', // 'bottom'/'right', the default is bottom
title: 'title',
subTitle: 'subTitle',
width: '60%', // The setting is valid when placement='right', the default is '70%'
height: '60%', // The setting is valid when placement='bottom', the default is '80%'
showNewOpen: false, // Whether to display the newOpen button, the default is true
theme: 'WHITE', // 'DARK'/'WHITE', the default is the current theme color of the App Portal
maskClosable: 'true', // Whether to close the Drawer when clicking on the mask, the default is false
destroyOnClose: 'false' // Whether to destroy the inner child elements of the drawer when it is closed, the default is true
}
Close App Portal Drawer
Call example
appPortalSDK.useDrawer();
18.useModal
Raise App Portal Modal
Call example
appPortalSDK.useModal(urlData, componentData, type = 1);
urlData = {
url: 'xxxx', // The URL of the page opened inside the modal
}
componentData = {
title: 'title',
size: 'large', // 'small'/'medium'/'large', used to set the modal width, the default is medium
height: 340, // The content height of the modal. After setting, the height range of the modal is 200px-600px. If over or under the height range of the modal, it will be displayed according to the extreme value
theme: 'WHITE', // 'DARK'/'WHITE', the default is the current theme color of the App Portal
maskClosable: 'true', // Whether to close the Modal when clicking on the mask, the default is false
destroyOnClose: 'false' // Whether to destroy the inner child elements of the Modal when it is closed, the default is true
}
type = 1 / 2 // 1 represents a normal Modal, 2 represents a double confirm Modal
Close App Portal Modal
Call example
appPortalSDK.useModal();
19.showMessage
Display the prompt message of the interface call
Call example
appPortalSDK.showMessage(type = 'success', 'message'); // type = 'success'/'failed'/'warning'
20.setConfig
Enable lite mode
Call example
appPortalSDK.setConfig({
appId: 'abcd', // Required
liteMode: true, // Required
token: 'efgh' // Optional, if not passed, the value will be taken from localStorage, and the key value will be consistent with the original sdk
});
21.getVisitRecords
Get the latest visit record
Call example
appPortalSDK.getVisitRecords();
Return example
[
{
"appId": "abcd"
"menuCode": "menu21"
"menuName": "menu21"
"url": "defg"
}
]
22.useWindow
Raise App Portal floating window
Call example
appPortalSDK.useWindow(winConfig);
winConfig = {
code: 'xxxx', // Floating window component identifier code, required
url: 'xxxx', // The URL of the page opened inside the floating window
width: 480,
height: 320,
top: 50,
right: 20,
bottom: 50, // When configuring together with top, take the top value
left: 20, // When configuring together with right, take the left value
autoDestroy: false, // Automatically destroy floating windows when a page jumps, default value is true
mask: true, // Enable mask layer, default value false
visible: true, // Display floating window component, default false
undisturbed: true, // Enable undisturbed prompt, default value true
undisturbedAfterTimes: 2 // The number of times required to enable undisturbed mode, with a default value of 3
}
Close App Portal floating window
Call example
appPortalSDK.useWindow({code: 'xxxx'});
Get App Portal floating window data
Call example
appPortalSDK.getWindowData({code: 'xxx', incrementalUpdate: true}); // Incremental data
appPortalSDK.getWindowData({code: 'xxx'}); // All data
23.setLocale
Set language
Call example
appPortalSDK.setLocale('en-US');
Version Dependency
SDK version | app portal version ---------|---------- 0.1.12 | >=2.4.6-r-2 0.1.11 | >=2.4.6-r-1 0.1.10 | >=2.4.9 0.1.7 | >=2.4.8 0.1.6 | >=2.4.7 0.1.1 | >=2.4.4 0.0.16 | >=2.3.14 0.0.15 | >=2.3.10
Release Notes:
v0.1.12
- Add useWindow function and getWindowData function.
- Add a new view mode with a viewMode value of 4.
- Add setLocale function.
v0.1.11
- The switchPage method adds a viewMode parameter to support specifying the view mode when switching pages.
- Add a new view mode with a viewMode value of 3.
v0.1.10
- The getAppAssets method adds parameters to specify the resource type returned. By default, the default value is ['auth_unit', 'logic_unit'], which can be configured according to ou. Passing ['all'] means that all types are required.
v0.1.9
- Update readme。
v0.1.8
- Fix cross-domain error.
v0.1.7
- The getUserInfo method of the lite mode adds mailbox RSA decryption.
- Modify the getAppAssets and getStructureByDetail method call examples.
- Add the getVisitRecords method to get the latest visit record under the new navigation.
v0.1.6
- The getAppAssets and getStructureByDetail methods add parameters to request associated resources, and the default value is false to not request associated resources.
v0.1.5
- Fix the bug of token loss in lite mode.
v0.1.4
- Fix the bug that the getAppAssets method of the lite mode fails to get the data when the promise method error is called repeatedly.
- Update the readme and add an example of enabling lite mode.
v0.1.3
- Fix the failure of getStructureByDetail, setBeforeLeave, setHelpUrl, setNotificationUrl, setPageTitle, setViewMode, showMessage, toggleMenu, useDrawer, useModal and switchPage methods caused by changes in the internal parameter passing method of v0.1.1.
- The lite mode is added. After enabling it, the sdk can directly request the interface to obtain the corresponding data under the same domain as the App Portal. The lite version supports getAppAssets, getAppInfo, getAvailableLocales, getLocale, getStructureByApp, getStructureByDetail, getTheme, getUserInfo, and openLink.
v0.1.2
- Update the examples returned by the getUserInfo, getAppInfo and getAppAssets methods.
v0.1.1
- Add an addToVisitRecord parameter for switchPage function to determine whether the switch page needs to be added to the visited records
- Optimize the communication method, directly obtain the data mounted on the window when the application and the app portal are not cross-domain
v0.0.17
- Fixed the bug that the data of the desired app portal could not be obtained when there were multiple app portals
V0.0.16
- add useDrawer function and useModal function
- add showMessage function
V0.0.15
- add getStructureByApp function and getStructureByDetail function
- add setBeforeLeave function
V0.0.14
- add compatibility handling
- This version is recommended to be used with the App Portal of version GA2.2.0
V0.0.13
- add getTheme function
v0.0.11
- add getAvailableLocales function
- remove 404 check
v0.0.5
- Added the option to open a page on a new tab for
switchPage
. - Added the
openLink
option.
V0.0.4
- Added support for switching pages by using appCode.
V0.0.3
- Added toggleMenu API.
v0.0.2
- Obfuscated the compression code.
- Added verification to check if an application is running in the app portal. If it is not running, SDK functions will reject the request.
- Tweaked the code structure.
v0.0.
- Provided an SDK Module based on ES5.
- Added API for big-screen mode and full-screen mode.
- Modified the menu URL configuration rules to enable relative paths.
- Added appId, menuCode, categoryId, and locale to content queries for rendering.
- Enhanced load and call speeds.
- Modified the README content.