Commit 680f6010 authored by xuchaozou's avatar xuchaozou

feat: 增加子包iframe通信功能

parent 4951947b
Pipeline #90036 passed with stages
......@@ -22,12 +22,16 @@ class SecurityLayout extends React.Component {
document.title = this.props.global.title;
if (window.share && window.share.event) {
window.share.event.on('event:logoutPackage', this.handleLogoutPackage);
window.share.event.on("iframe:postMessage", this.handleIframePostMessage)
window.share.event.once("event:isHasFrame", this.handleIsHasFrame)
}
}
componentWillUnmount() {
if (window.share && window.share.event) {
window.share.event.removeListener('event:logoutPackage', this.handleLogoutPackage);
window.share.event.removeListener("iframe:postMessage", this.handleIframePostMessage)
window.share.event.removeListener("event:isHasFrame", this.handleIframePostMessage)
}
}
......@@ -36,6 +40,19 @@ class SecurityLayout extends React.Component {
logout && logout();
}
//发送消息,因为子包无法通信
handleIframePostMessage (data) {
if(!(window.parent && data)) return
window.parent.postMessage(data, "*")
}
//获取当前页面是否嵌套
handleIsHasFrame() {
window.share.event.emit("event:getHasFrame", {
hasFrame : window != window.parent
})
}
componentWillReceiveProps(nextProps) {
const products = (this.props.global.products || []).map(item => {
if (item.PackageName === 'civweb4') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment