iframe-tab-sdk 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/index.js +16 -13
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ iframe微前端集成, 顶部tab页操作;支持独立运行
|
|
|
5
5
|
## API
|
|
6
6
|
|方法名|说明|参数|类型
|
|
7
7
|
|:----|:----|:----|:----
|
|
8
|
-
|openTab|打开tab页|
|
|
9
|
-
|refreshTab|刷新tab页|
|
|
8
|
+
|openTab|打开tab页|[openRoute](#openroute-attributes),详见下表|object
|
|
9
|
+
|refreshTab|刷新tab页|[openRoute](#openroute-attributes)|object
|
|
10
10
|
|closeTab|关闭tab页|urlPath|string
|
|
11
11
|
|logout|退出登录|无|无
|
|
12
12
|
|reload|刷新主应用网页|无|无
|
|
13
|
-
|closeAndOpenTab|关闭当前tab并新开tab|
|
|
13
|
+
|closeAndOpenTab|关闭当前tab并新开tab|{ [openRoute](#openroute-attributes), closeTabName,message }|object
|
|
14
14
|
|fullscreen|全屏/退出全屏|isFullScreen|boolean
|
|
15
15
|
|
|
16
16
|
### openRoute Attributes
|
|
@@ -27,7 +27,7 @@ iframe微前端集成, 顶部tab页操作;支持独立运行
|
|
|
27
27
|
## 示例(vue+elementui)
|
|
28
28
|
``` vue
|
|
29
29
|
<template>
|
|
30
|
-
<el-button type="primary" @click="closeAndOpenTab(
|
|
30
|
+
<el-button type="primary" @click="closeAndOpenTab({openRoute,closeTabName: '/console/user/add',message:'用户添加成功!' })">关闭当前tab并打开新的tab页</el-button>
|
|
31
31
|
</template>
|
|
32
32
|
<script>
|
|
33
33
|
import {closeAndOpenTabAsIframe} from 'iframe-tab-sdk'
|
|
@@ -48,4 +48,4 @@ export default {
|
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
50
50
|
|
|
51
|
-
```
|
|
51
|
+
```
|
package/index.js
CHANGED
|
@@ -64,15 +64,15 @@ function navigateTo(urlPath, query = {}) {
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* 新开或跳转 tab 标签页
|
|
67
|
-
* @param {
|
|
68
|
-
* @param {
|
|
67
|
+
* @param {String} params 参数
|
|
68
|
+
* @param {Object} params[urlPath] 页面地址
|
|
69
69
|
* @param {String} params[name] 页面名称
|
|
70
70
|
* @param {String} params[title] 页面标题
|
|
71
71
|
* @param {Object} params[query] query 参数
|
|
72
|
-
* @param {Boolean} params[refreshClearQuery] 是否清空路由参数
|
|
73
72
|
*
|
|
74
73
|
*/
|
|
75
|
-
export function openTab(params) {
|
|
74
|
+
export function openTab( params) {
|
|
75
|
+
const { urlPath, query = {} } = params;
|
|
76
76
|
if (window.isIframeRun) {
|
|
77
77
|
window.parent.postMessage(
|
|
78
78
|
{
|
|
@@ -82,7 +82,6 @@ export function openTab(params) {
|
|
|
82
82
|
origin
|
|
83
83
|
);
|
|
84
84
|
} else {
|
|
85
|
-
const { urlPath, query = {} } = params;
|
|
86
85
|
// 非iframe环境,执行路由跳转
|
|
87
86
|
navigateTo(urlPath, query);
|
|
88
87
|
}
|
|
@@ -90,24 +89,22 @@ export function openTab(params) {
|
|
|
90
89
|
|
|
91
90
|
/**
|
|
92
91
|
* 刷新指定 tab 标签页
|
|
92
|
+
* @param {String} urlPath 指定 tab 标签页 URL
|
|
93
93
|
* @param {Object} params 相关参数
|
|
94
|
-
* @param {String} params[urlPath] 指定 tab 标签页 URL
|
|
95
94
|
* @param {String} params[name] 页面名称
|
|
96
95
|
* @param {String} params[title] 页面标题
|
|
97
96
|
* @param {Object} params[query] query 参数
|
|
98
97
|
*/
|
|
99
|
-
export function refreshTab(params) {
|
|
100
|
-
const urlPath = params.urlPath;
|
|
98
|
+
export function refreshTab(urlPath, params) {
|
|
101
99
|
if (window.isIframeRun) {
|
|
102
100
|
if (params) {
|
|
103
|
-
return openTab(params);
|
|
101
|
+
return openTab({...params.urlPath});
|
|
104
102
|
}
|
|
105
|
-
|
|
106
103
|
window.parent.postMessage({ type: "refreshTab", params: urlPath }, origin);
|
|
107
104
|
} else {
|
|
108
105
|
// 非iframe环境下,重新导航到指定路径
|
|
109
106
|
if (params) {
|
|
110
|
-
return openTab(params);
|
|
107
|
+
return openTab({...params,urlPath});
|
|
111
108
|
}
|
|
112
109
|
navigateTo(urlPath, {});
|
|
113
110
|
}
|
|
@@ -156,8 +153,15 @@ export function reload() {
|
|
|
156
153
|
|
|
157
154
|
/**
|
|
158
155
|
* 关闭某个tab打开新的tab(常用于关闭自身tab并打开新tab)
|
|
156
|
+
* @param {Object} params 相关参数
|
|
157
|
+
* @param {Object} params[openRoute] 跳转的页面信息
|
|
158
|
+
* @param {String} params[closeTabName] 关闭的页面路由
|
|
159
|
+
* @param {Object} params[message] 操作完成后的页面提示信息
|
|
160
|
+
*
|
|
159
161
|
*/
|
|
160
162
|
export function closeAndOpenTab(params) {
|
|
163
|
+
const { openRoute } = params;
|
|
164
|
+
|
|
161
165
|
if (window.isIframeRun) {
|
|
162
166
|
window.parent.postMessage(
|
|
163
167
|
{
|
|
@@ -167,9 +171,8 @@ export function closeAndOpenTab(params) {
|
|
|
167
171
|
origin
|
|
168
172
|
);
|
|
169
173
|
} else {
|
|
170
|
-
const {urlPath,query} = params;
|
|
171
174
|
// 非iframe环境,直接跳转到新页面
|
|
172
|
-
navigateTo(urlPath, query);
|
|
175
|
+
navigateTo(openRoute.urlPath, openRoute.query);
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iframe-tab-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "门户iframe集成子应用顶部tab页管理",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"private": false,
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
},
|
|
11
11
|
"keywords": ["iframe", "tab", "集成", "微前端"],
|
|
12
12
|
"author": "wy",
|
|
13
|
-
"license": "
|
|
14
|
-
}
|
|
13
|
+
"license": "MIT"
|
|
14
|
+
}
|