|
@@ -1,37 +1,33 @@
|
|
|
import { FC, useEffect } from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
+import { baseURL } from "@/utils/http";
|
|
|
+import { pcIframeObj } from "./data";
|
|
|
|
|
|
interface IframePageProps {
|
|
|
filename: string;
|
|
|
title: string;
|
|
|
}
|
|
|
|
|
|
-const IframePage: FC<IframePageProps> = ({title, filename}) => {
|
|
|
+const IframePage: FC<IframePageProps> = ({ title, filename }) => {
|
|
|
useEffect(() => {
|
|
|
window.addEventListener("message", unityCallUrl);
|
|
|
}, []);
|
|
|
|
|
|
const unityCallUrl = (e: MessageEvent<any>) => {
|
|
|
if (!e.data || !e.data.index) return;
|
|
|
- switch (e.data.index) {
|
|
|
- case '3':
|
|
|
- // 虎门故事陈列
|
|
|
- window.open('https://www.4dkankan.com/spg.html?m=KJ-7NjKB1ssebo&lang=zh');
|
|
|
- break;
|
|
|
- case '2':
|
|
|
- // 虎门销烟陈列
|
|
|
- window.open('https://www.4dkankan.com/spg.html?m=KJ-dSR2wuQUDgD&lang=zh');
|
|
|
- break;
|
|
|
- default:
|
|
|
- // 海战馆
|
|
|
- window.open('https://www.4dkankan.com/spg.html?m=KJ-I6rH3CfNSQV&lang=zh');
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- return <iframe title={title}
|
|
|
- className={styles.MapSon}
|
|
|
- src={`./${filename}/index.html`}
|
|
|
- />
|
|
|
-}
|
|
|
+ const url = Reflect.get(pcIframeObj, e.data.index + "");
|
|
|
+
|
|
|
+ window.open(url);
|
|
|
+ };
|
|
|
+
|
|
|
+ return (
|
|
|
+ <iframe
|
|
|
+ title={title}
|
|
|
+ className={styles.MapSon}
|
|
|
+ src={`${baseURL}/pc/unityPage/${filename}/index.html`}
|
|
|
+ />
|
|
|
+ );
|
|
|
+};
|
|
|
|
|
|
-export default IframePage
|
|
|
+export default IframePage;
|