{"id":20875890,"url":"https://github.com/saqqdy/postmessager","last_synced_at":"2025-05-12T15:31:52.107Z","repository":{"id":53203194,"uuid":"386214099","full_name":"saqqdy/postmessager","owner":"saqqdy","description":"iframe postmessage通信整体方案","archived":false,"fork":false,"pushed_at":"2023-06-14T05:13:35.000Z","size":424,"stargazers_count":13,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-26T05:27:45.599Z","etag":null,"topics":["iframe","iframe-tool","postmessage","postmessage-tool"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saqqdy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["saqqdy"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2021-07-15T08:10:17.000Z","updated_at":"2023-03-07T14:19:20.000Z","dependencies_parsed_at":"2024-11-18T06:49:11.311Z","dependency_job_id":"3dfb7498-5ae3-46d6-8917-8692329cff0a","html_url":"https://github.com/saqqdy/postmessager","commit_stats":{"total_commits":76,"total_committers":4,"mean_commits":19.0,"dds":0.4736842105263158,"last_synced_commit":"70fc7ef192a17ec42a5e0dbfcf3ddcd86ba36828"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Fpostmessager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Fpostmessager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Fpostmessager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saqqdy%2Fpostmessager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saqqdy","download_url":"https://codeload.github.com/saqqdy/postmessager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253765925,"owners_count":21960819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iframe","iframe-tool","postmessage","postmessage-tool"],"created_at":"2024-11-18T06:48:59.724Z","updated_at":"2025-05-12T15:31:51.836Z","avatar_url":"https://github.com/saqqdy.png","language":"TypeScript","funding_links":["https://github.com/sponsors/saqqdy"],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"text-align: center;\" align=\"center\"\u003e\n\n# postmessager\n\n这是一个 iframe postmessage 通信整体方案\n\n[![NPM version][npm-image]][npm-url]\n[![Codacy Badge][codacy-image]][codacy-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n[![gzip][gzip-image]][gzip-url]\n[![License][license-image]][license-url]\n\n[![Sonar][sonar-image]][sonar-url]\n\n## **完整文档请查阅： [API 完整文档](./docs/classes/default.md)**\n\n\u003c/div\u003e\n\n## 介绍\n\npostmessager\n\n## 安装教程\n\n```shell\n# 通过npm安装\nnpm install --save postmessager\n# 或者通过yarn安装\nyarn add postmessager\n```\n\n## 通过 import 引入模块的方式\n\n```js\n// 在你的.vue或者main.js里面写上import\nimport PostMessager from 'postmessager'\n```\n\n## 使用文件引入的方式\n\n1. 通过 require 引入\n\n    ```js\n    // 在你的main.js文件里面加上下面这一行\n    const PostMessager = require('postmessager')\n    ```\n\n2. html 静态页直接使用\n\n    ```html\n    \u003c!-- 在你的html代码上加上script标签，使用CDN链接引入 --\u003e\n    \u003cscript src=\"https://unpkg.com/postmessager@latest/dist/index.min.js\"\u003e\u003c/script\u003e\n    ```\n\n## 使用\n\n### 1. 在 vue 中使用\n\n```vue\n\u003cscript\u003e\nimport PostMessager from 'postmessager'\n\nexport default {\n    data() {\n        return {\n            messager: null\n        }\n    },\n    created() {\n        this.messager = new PostMessager(this, 'invokeCustomEvent')\n        this.messager.subscribe('getQuery', this.getQuery)\n    },\n    methods: {\n        getQuery(data) {\n            console.log(data)\n        }\n    }\n}\n\u003c/script\u003e\n```\n\n### 2. js 项目中使用\n\n```js\nconst messager = new PostMessager()\nmessager.subscribe('getQuery', getQuery)\nmessager.postMessageUp('actionName', {})\nmessager.postMessageDown('iframeName', 'actionName', {})\n\nfunction getQuery(data) {\n    console.log(data)\n}\n```\n\n## 参与贡献\n\n1. Fork 本仓库\n2. 新建 Feat_xxx 分支\n3. 提交代码\n4. 新建 Pull Request\n\n## 我的相关\n\n-   **_使用_** _Readme_XXX.md_ 来支持不同的语言，`例如` _Readme_en.md, Readme_zh.md_\n-   我的 Github：[https://github.com/saqqdy](https://github.com/saqqdy)\n-   我的 npm：[https://npmjs.com/~saqqdy](https://npmjs.com/~saqqdy)\n-   我的个人网站 [http://www.saqqdy.com](http://www.saqqdy.com)\n\n[npm-image]: https://img.shields.io/npm/v/postmessager.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/postmessager\n[codacy-image]: https://app.codacy.com/project/badge/Grade/f70d4880e4ad4f40aa970eb9ee9d0696\n[codacy-url]: https://www.codacy.com/gh/saqqdy/postmessager/dashboard?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=saqqdy/postmessager\u0026utm_campaign=Badge_Grade\n[travis-image]: https://travis-ci.com/saqqdy/postmessager.svg?branch=master\n[travis-url]: https://travis-ci.com/saqqdy/postmessager\n[codecov-image]: https://img.shields.io/codecov/c/github/saqqdy/postmessager.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/saqqdy/postmessager?branch=master\n[download-image]: https://img.shields.io/npm/dm/postmessager.svg?style=flat-square\n[download-url]: https://npmjs.org/package/postmessager\n[gzip-image]: http://img.badgesize.io/https://unpkg.com/postmessager/lib/index.js?compression=gzip\u0026label=gzip%20size:%20JS\n[gzip-url]: http://img.badgesize.io/https://unpkg.com/postmessager/lib/index.js?compression=gzip\u0026label=gzip%20size:%20JS\n[license-image]: https://img.shields.io/badge/License-MIT-yellow.svg\n[license-url]: LICENSE\n[sonar-image]: https://sonarcloud.io/api/project_badges/quality_gate?project=saqqdy_postmessager\n[sonar-url]: https://sonarcloud.io/dashboard?id=saqqdy_postmessager\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaqqdy%2Fpostmessager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaqqdy%2Fpostmessager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaqqdy%2Fpostmessager/lists"}