|
@@ -1,13 +1,18 @@
|
|
|
/* eslint-disable jsx-a11y/iframe-has-title */
|
|
|
import { RootState } from "@/store";
|
|
|
import { modelItem } from "@/types";
|
|
|
-import { useEffect, useRef, useState } from "react";
|
|
|
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
import { useSelector } from "react-redux";
|
|
|
import musicImg from "@/assets/img/music.png";
|
|
|
import musicImgAc from "@/assets/img/musicAc.png";
|
|
|
import styles from "./index.module.scss";
|
|
|
import { baseURL } from "@/utils/http";
|
|
|
import classNames from "classnames";
|
|
|
+import LogoImg from '@/assets/img/logo.png';
|
|
|
+import ModelBacTopImg from '@/assets/img/modelBacTop.png';
|
|
|
+import ModelBacLeftImg from '@/assets/img/modelBacLeft.png';
|
|
|
+import ModelBacRightImg from '@/assets/img/modelBacRight.png';
|
|
|
+import ModelBacBottomImg from '@/assets/img/modelBacBottom.png';
|
|
|
|
|
|
type props = {
|
|
|
modelId: number;
|
|
@@ -17,10 +22,42 @@ export default function Model({ modelId, closeModel }: props) {
|
|
|
const { modelInfo } = useSelector((state: RootState) => state.homeStore);
|
|
|
const { list } = modelInfo;
|
|
|
const [info, setInfo] = useState({} as modelItem);
|
|
|
+ // const [videoPlay, setVideoPlay] = useState(true);
|
|
|
+ const [infoVisible, setInfoVisible] = useState(false);
|
|
|
+ const modelBorderLRef = useRef<any>(null);
|
|
|
+ const modelBorderRRef = useRef<any>(null);
|
|
|
+ const [modelBorderRect, setModelBorderRect] = useState({
|
|
|
+ leftWidth: 0,
|
|
|
+ rightWidth: 0
|
|
|
+ });
|
|
|
+ const modelBorderStyle = useMemo(() => ({
|
|
|
+ left: modelBorderRect.leftWidth + 'px',
|
|
|
+ width: `calc(100% - ${modelBorderRect.leftWidth}px - ${modelBorderRect.rightWidth}px)`,
|
|
|
+ height: modelBorderRect.leftWidth - 1 + 'px'
|
|
|
+ }), [modelBorderRect]);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ window.addEventListener('resize', getModelBorderRect);
|
|
|
+
|
|
|
+ return () => {
|
|
|
+ window.removeEventListener('resize', getModelBorderRect);
|
|
|
+ }
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ const getModelBorderRect = () => {
|
|
|
+ if (modelBorderLRef.current && modelBorderRRef.current) {
|
|
|
+ // 获取左右边框宽度
|
|
|
+ setModelBorderRect({
|
|
|
+ leftWidth: modelBorderLRef.current.getBoundingClientRect().width,
|
|
|
+ rightWidth: modelBorderRRef.current.getBoundingClientRect().width
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
const closeModelFu = () => {
|
|
|
setInfo({} as modelItem);
|
|
|
setMusic(false);
|
|
|
+ setInfoVisible(false);
|
|
|
closeModel();
|
|
|
};
|
|
|
useEffect(() => {
|
|
@@ -73,6 +110,25 @@ export default function Model({ modelId, closeModel }: props) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ // 控制模型播放
|
|
|
+ // const handleVideoStatus = useCallback(() => {
|
|
|
+ // const dom = ifrBoxRef.current;
|
|
|
+ // if (!dom) return;
|
|
|
+
|
|
|
+ // const status = !videoPlay;
|
|
|
+ // if (!status) {
|
|
|
+ // dom.contentWindow.webview.stopRotate(true);
|
|
|
+ // } else {
|
|
|
+ // dom.contentWindow.webview.rotateWhenIdle();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // setVideoPlay(status);
|
|
|
+ // }, [videoPlay]);
|
|
|
+
|
|
|
+ const handleInfoVisible = useCallback(() => {
|
|
|
+ setInfoVisible(!infoVisible);
|
|
|
+ }, [infoVisible]);
|
|
|
+
|
|
|
return (
|
|
|
<div className={styles.Model}>
|
|
|
{/* 音频 */}
|
|
@@ -89,42 +145,23 @@ export default function Model({ modelId, closeModel }: props) {
|
|
|
></iframe>
|
|
|
) : null}
|
|
|
</div>
|
|
|
+
|
|
|
+ <img src={LogoImg} className="logo" />
|
|
|
+
|
|
|
{/* 右边介绍 */}
|
|
|
- <div
|
|
|
- className={classNames(
|
|
|
- "rightTxt",
|
|
|
- info.isDetail === 0 ? "nullRightTxt" : ""
|
|
|
- )}
|
|
|
- >
|
|
|
- <div className="model_title">{info.name}</div>
|
|
|
- {info.description ? (
|
|
|
- <div
|
|
|
- className="model_txt"
|
|
|
- dangerouslySetInnerHTML={{ __html: info.description }}
|
|
|
- ></div>
|
|
|
- ) : (
|
|
|
- <div className="model_txt">暂无信息</div>
|
|
|
- )}
|
|
|
-
|
|
|
- <div className="model_floo">
|
|
|
- <div className="model_sortRow">
|
|
|
- 类别:
|
|
|
- <p>{info.dictTextureName ? info.dictTextureName : "(空)"}</p>
|
|
|
- </div>
|
|
|
- <div className="model_ageRow">
|
|
|
- 年代:
|
|
|
- <p>{info.dictAgeName ? info.dictAgeName : "(空)"}</p>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- {
|
|
|
- <div className="model_size">
|
|
|
- 尺寸:
|
|
|
- <p title={info.sizeLength}>
|
|
|
- {info.sizeLength ? info.sizeLength : "(空)"}
|
|
|
- </p>
|
|
|
- </div>
|
|
|
- }
|
|
|
+ <div className="right-info">
|
|
|
+ <div className="right-info_name">{info.name}</div>
|
|
|
+
|
|
|
+ {infoVisible && <>
|
|
|
+ <div className="right-info_line">类别:{info.dictTextureName || "(空)"}</div>
|
|
|
+ <div className="right-info_line">时代:{info.dictAgeName || "(空)"}</div>
|
|
|
+ <div className="right-info_line">尺寸:{info.sizeLength || "(空)"}</div>
|
|
|
+ {!!info.description && (
|
|
|
+ <div className="right-info_line">说明:{info.description || "(空)"}</div>
|
|
|
+ )}
|
|
|
+ </>}
|
|
|
+
|
|
|
+ {!!info.isDetail && <div className={classNames('right-info_btn', infoVisible && 'hidden')} onClick={handleInfoVisible} />}
|
|
|
</div>
|
|
|
|
|
|
{/* 底部按钮 */}
|
|
@@ -139,6 +176,21 @@ export default function Model({ modelId, closeModel }: props) {
|
|
|
title="缩小"
|
|
|
onClick={() => modelChangeFu(2)}
|
|
|
></div>
|
|
|
+ {/* <div
|
|
|
+ className={classNames('flootRow', 'flootRow5', videoPlay && 'active')}
|
|
|
+ title={videoPlay ? '暂停' : '播放'}
|
|
|
+ onClick={handleVideoStatus}
|
|
|
+ ></div> */}
|
|
|
+ <div
|
|
|
+ className="flootRow flootRow4"
|
|
|
+ title="重置"
|
|
|
+ onClick={() => modelChangeFu(3)}
|
|
|
+ ></div>
|
|
|
+ <div
|
|
|
+ className="flootRow flootRow3"
|
|
|
+ title="退出"
|
|
|
+ onClick={() => closeModelFu()}
|
|
|
+ ></div>
|
|
|
{info.audioPath ? (
|
|
|
<div
|
|
|
className="flootRow flootRowM"
|
|
@@ -151,17 +203,13 @@ export default function Model({ modelId, closeModel }: props) {
|
|
|
)}
|
|
|
</div>
|
|
|
) : null}
|
|
|
+ </div>
|
|
|
|
|
|
- <div
|
|
|
- className="flootRow flootRow4"
|
|
|
- title="重置"
|
|
|
- onClick={() => modelChangeFu(3)}
|
|
|
- ></div>
|
|
|
- <div
|
|
|
- className="flootRow flootRow3"
|
|
|
- title="退出"
|
|
|
- onClick={() => closeModelFu()}
|
|
|
- ></div>
|
|
|
+ <div style={{opacity: !!modelBorderRect.leftWidth ? 1 : 0}}>
|
|
|
+ <img src={ModelBacTopImg} className="modelBorderTop" style={modelBorderStyle} onLoad={getModelBorderRect} />
|
|
|
+ <img ref={modelBorderLRef} src={ModelBacLeftImg} className="modelBorderLeft" />
|
|
|
+ <img src={ModelBacBottomImg} className="modelBorderBottom" style={modelBorderStyle} />
|
|
|
+ <img ref={modelBorderRRef} src={ModelBacRightImg} className="modelBorderRight" />
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|