bug fix - refresh

master
Aaron Yu 2021-12-27 23:56:48 +08:00
parent d3befe3723
commit dde482801e
1 changed files with 5 additions and 6 deletions

View File

@ -48,17 +48,17 @@ var configMap = {
function DeviceFrame(props) {
var [config, setConfig] = useState({})
var [iframeKey, setIframeKey] = useState(100000);
var [cacheKey, setCacheKey] = useState(new Date().getTime());
useEffect(() => {
setConfig(configMap[props.device])
}, [props.device, config])
var refresh = () => setIframeKey(Math.round(Math.random() * 10000));
var refresh = () => setCacheKey(new Date().getTime());
useEffect(() => {
console.log(props.htmlUrl)
refresh()
console.log('触发更新', props.htmlUrl);
refresh();
props.refreshQrCode()
}, [props.htmlUrl])
@ -76,7 +76,6 @@ function DeviceFrame(props) {
{
props.htmlUrl
&& <iframe
key={iframeKey}
id='deviceFrame'
style={{
position: 'absolute',
@ -86,7 +85,7 @@ function DeviceFrame(props) {
paddingBottom: config.offsetv
}}
title='preview'
src={baseUrl + props.htmlUrl + '?time=' + new Date().getTime()}
src={baseUrl + props.htmlUrl + '?cacheKey=' + cacheKey}
width={config.width}
height={config.height}
frameBorder={'0'}/>