iframe-tab-sdk 1.0.0

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.
Files changed (3) hide show
  1. package/README.md +44 -0
  2. package/index.js +12 -0
  3. package/package.json +14 -0
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ ## iframe-tab-sdk
2
+
3
+ iframe微前端集成, 顶部tab页操作
4
+
5
+ ## API
6
+ |方法名|说明|参数|类型
7
+ |:----|:----|:----|:----
8
+ |closeTabAsIframe|关闭操作; 参数为要关闭tab的路径|routePath|string
9
+ |closeAndOpenTabAsIframe|关闭当前tab并新开tab|{openRoute(参数如下),closeTabName:'/xx/xx',message:''}|object
10
+ |openTabAsIframe|新开tab|openRoute|object
11
+
12
+ ### openRoute Attributes
13
+ |参数|类型|必填|说明
14
+ |:----|:----|:----|:----
15
+ |urlPath|string|是|tab页对应的路由(需加上子应用前缀)
16
+ |title|string|是|tab页标题
17
+ |params|object|否|params路由参数
18
+ |query|object|否|query路由参数
19
+
20
+ ## 示例(vue+elementui)
21
+ ``` vue
22
+ <template>
23
+ <el-button type="primary" @click="closeAndOpenTabAsIframe({openRoute,closeTabName: '/console/user/add',message:'用户添加成功!' })">关闭当前tab并打开新的tab页</el-button>
24
+ </template>
25
+ <script>
26
+ import {closeAndOpenTabAsIframe} from 'iframe-tab-sdk'
27
+ export default {
28
+ data() {
29
+ return {
30
+ openRoute: {
31
+ urlPath: '/console/user/list',
32
+ title: '新tab',
33
+ params: {}, // 非必填
34
+ query: {}, // 非必填
35
+ }
36
+ }
37
+ },
38
+ methods: {
39
+ closeAndOpenTabAsIframe
40
+ }
41
+ }
42
+ </script>
43
+
44
+ ```
package/index.js ADDED
@@ -0,0 +1,12 @@
1
+ // 作为子应用运行时, 关闭tab
2
+ export const closeTabAsIframe = (tabName) => {
3
+ window.parent.postMessage({type: 'closeTab',params: tabName},'*')
4
+ }
5
+ // 作为子应用运行时, 关闭当前tab并新开tab
6
+ export const closeAndOpenTabAsIframe = (params) => {
7
+ window.parent.postMessage({type: 'closeAndOpenTab',params},'*')
8
+ }
9
+ // 作为子应用运行时, 打开tab
10
+ export const openTabAsIframe = (params) => {
11
+ window.parent.postMessage({type: 'openTab',params},'*')
12
+ }
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "iframe-tab-sdk",
3
+ "version": "1.0.0",
4
+ "description": "门户iframe集成子应用顶部tab页管理",
5
+ "main": "index.js",
6
+ "private": false,
7
+ "homepage": "https://gitee.com/weixiaoyun/iframe-tab-sdk/blob/master/README.md",
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "keywords": ["iframe", "tab", "集成", "微前端"],
12
+ "author": "wy",
13
+ "license": "ISC"
14
+ }