巴林闲侠
2 years ago
5 changed files with 57 additions and 3 deletions
@ -1,5 +1,6 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
import MonitorCenter from './monitorCenter'; |
import MonitorCenter from './monitorCenter'; |
||||
|
import VideoPlayCross from './videoPlayCross'; |
||||
|
|
||||
export { MonitorCenter }; |
export { MonitorCenter, VideoPlayCross }; |
@ -0,0 +1,43 @@ |
|||||
|
import React, { useEffect, useState } from 'react'; |
||||
|
import { connect } from 'react-redux'; |
||||
|
import { VideoPlay } from '$components' |
||||
|
import '../style.less' |
||||
|
|
||||
|
const VideoPlayCross = (props) => { |
||||
|
const [videoParams, setVideoParams] = useState(null) |
||||
|
|
||||
|
useEffect(() => { |
||||
|
function messageListen (e) { |
||||
|
// 此处需做 域名 验证 |
||||
|
const { data } = e |
||||
|
if (data && data.action) { |
||||
|
if (data.action == 'init_video') { |
||||
|
setVideoParams(data.params) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (window.parent) { |
||||
|
window.addEventListener('message', messageListen); |
||||
|
} |
||||
|
return () => { |
||||
|
window.removeEventListener('message', messageListen); |
||||
|
} |
||||
|
}, []) |
||||
|
return ( |
||||
|
<> |
||||
|
{ |
||||
|
videoParams && <VideoPlay {...videoParams} /> |
||||
|
} |
||||
|
</> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
function mapStateToProps (state) { |
||||
|
const { auth } = state; |
||||
|
return { |
||||
|
user: auth.user, |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
export default connect(mapStateToProps)(VideoPlayCross); |
Loading…
Reference in new issue