|
|
@ -0,0 +1,30 @@ |
|
|
|
|
|
import React, { useEffect, useState, useRef } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
function TrendPrediction() { |
|
|
|
|
|
const iframeRef = useRef(null); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
if (iframeRef.current) { |
|
|
|
|
|
iframeRef.current.contentWindow.addEventListener('message', (event) => { |
|
|
|
|
|
console.log(11111, event.data); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return () => { |
|
|
|
|
|
if (iframeRef.current) { |
|
|
|
|
|
iframeRef.current.contentWindow.removeEventListener('message', (event) => { |
|
|
|
|
|
console.log('Received message:', event.data); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
}, []); // 空依赖数组确保只运行一次清理操作 |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
<div> |
|
|
|
|
|
<iframe ref={iframeRef} src="http://ds1.chenhaitech.com/chat/TBbQM3inivFUO1yT" className='w-[100%] h-screen'/>; |
|
|
|
|
|
</div> |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default TrendPrediction; |