{"id":16422804,"url":"https://github.com/zhoutaoo/cross-domain","last_synced_at":"2025-03-21T03:33:48.693Z","repository":{"id":22393241,"uuid":"25730215","full_name":"zhoutaoo/cross-domain","owner":"zhoutaoo","description":"一个利用html5的跨域api postMessage解决多iframe跨域通信的框架","archived":false,"fork":false,"pushed_at":"2018-06-30T06:13:07.000Z","size":53,"stargazers_count":36,"open_issues_count":0,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-12T07:37:40.390Z","etag":null,"topics":["cross-domain","javascript","js","postmessage"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/zhoutaoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-25T12:09:23.000Z","updated_at":"2023-05-19T11:13:56.000Z","dependencies_parsed_at":"2022-07-25T13:17:13.536Z","dependency_job_id":null,"html_url":"https://github.com/zhoutaoo/cross-domain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhoutaoo%2Fcross-domain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhoutaoo%2Fcross-domain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhoutaoo%2Fcross-domain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhoutaoo%2Fcross-domain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhoutaoo","download_url":"https://codeload.github.com/zhoutaoo/cross-domain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221811374,"owners_count":16884305,"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":["cross-domain","javascript","js","postmessage"],"created_at":"2024-10-11T07:37:40.235Z","updated_at":"2024-10-28T09:17:57.411Z","avatar_url":"https://github.com/zhoutaoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"cross-domain\n============\n\n# 一个利用html5的跨域api postMessage解决多iframe跨域通信的js框架\n\n# 背景\n最初公司只有一个系统来做销售，随着公司业务越来越多，搭建很多类似的系统（这些系统本来是没有任何关系的，每个系统目前都非常复杂），由于目前公司战略有调整，原来的销售是针对某种产品，现在销售工作要针对客户进行多产品的销售促成，这样一个销售人员就需要打开各种系统进行业务操作，非常不方便，而且销售数据间不能有效传递，所就需要把各个不相关的系统整合在一起，实现跨业务线销售和数据共享。若将这想要将这些复杂系统整合在一起，无论是从人力物力上都是不太可能接受的。所以选择了使用iframe将各系统嵌入一个框架系统，各系统从物理上还是分开不变，而从逻辑上（从用户角度看就是一个系统）看起来是一个系统。然而各系统采用了不同的域名，与主框架和其它业务系统有跨域问题（若将所有域名改为同一域名下可能会产生一些系统间页面元素和样式的冲突），故采用了HTML5标准下的postMessage来解决该问题。\n# 介绍\n## 示意图\n![image](https://raw.githubusercontent.com/FreeLanderEden/cross-domain/master/example/principle.jpg)\n## 简介与使用\n请参考 [简介与使用](https://segmentfault.com/a/1190000015435530)\n# Feature\n## 组件自动注册机制\n页面及js加载完成后自动发送配置信息到master端进行注册，master接收到消息后将组件存储相关信息，无需手工进行任何初使化操作。\n## 消息自动回复机制\npostMessage为单项信息传递，若调用方发起调用后有值需要被调用方返回则需要被调用方主动发送，故希望实现若被调用方有值需要返回则自动回复给调用方，简化操作。\n## 消息自动路由机制\n组件间不能直接进行消息发送，全部需要经过master的路由和转发\n## 前端数据共享机制\n不同域名前端数据进行共享使用，解决组件间数据的频繁共享使用，原理是通过跨域方法对需要共享使用的数据自动转发到每个组件浏览器中的sessionStorage进行存储，关闭浏览器数据即清除。\n# Contributing\n欢迎大家提供想法和提交代码\n# License\nThe MIT License (MIT)\n\nCopyright (c) 2014 FreeLanderEden\n# Communication\n* WeChat：zhoutaoo\n* WeiBo：@zhoutaoo\n* EMail：zhoutaoo@foxmail.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhoutaoo%2Fcross-domain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhoutaoo%2Fcross-domain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhoutaoo%2Fcross-domain/lists"}