/* eslint-disable jsx-a11y/iframe-has-title */
import React, { useEffect, useState } from "react";
import styles from "./index.module.scss";
import backImg from "@/assets/img/goods/toBack.png";
import { baseURL } from "@/utils/http";

type Props = {
  closeFu: () => void;
  code: string;
};



function Scene({ closeFu, code }: Props) {
  // 给嵌套的场景页面调用，打开热点的时候 关闭返回按钮
  const [flag, setFlag] = useState(true);

  useEffect(() => {
    window.sceneBackIconStatus = (flag) => {
      setFlag(flag);
    };
  }, []);

  return (
    <div className={styles.Scene}>
      <img
        hidden={!flag}
        className="tab1Sback"
        onClick={closeFu}
        src={backImg}
        alt=""
      />
      <iframe
        src={`${baseURL}/scene/index.html?m=${code}`}
        frameBorder="0"
      ></iframe>
    </div>
  );
}

const MemoScene = React.memo(Scene);

export default MemoScene;
