|
@@ -1,7 +1,8 @@
|
|
|
import React, { useEffect, useState, useRef } from 'react'
|
|
import React, { useEffect, useState, useRef } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
import styles from './index.module.scss'
|
|
|
|
|
+import { TitleData } from '../../index'
|
|
|
|
|
|
|
|
-const FlipPic = ({ activeIndex }: { activeIndex: number }) => {
|
|
|
|
|
|
|
+const FlipPic = ({ titleData, activeIndex, setCurrentData }: { titleData: Record<string, TitleData[]>, activeIndex: number, setCurrentData: (data: TitleData) => void }) => {
|
|
|
const [prevIndex, setPrevIndex] = useState(activeIndex);
|
|
const [prevIndex, setPrevIndex] = useState(activeIndex);
|
|
|
const [isAnimating, setIsAnimating] = useState(true);
|
|
const [isAnimating, setIsAnimating] = useState(true);
|
|
|
const [displayIndex, setDisplayIndex] = useState(activeIndex);
|
|
const [displayIndex, setDisplayIndex] = useState(activeIndex);
|
|
@@ -40,38 +41,7 @@ const FlipPic = ({ activeIndex }: { activeIndex: number }) => {
|
|
|
}
|
|
}
|
|
|
}, [activeIndex, prevIndex]);
|
|
}, [activeIndex, prevIndex]);
|
|
|
|
|
|
|
|
- const title: Record<string, { name: string, link: string }[]> = {
|
|
|
|
|
- pic1: [{
|
|
|
|
|
- name: '元青花四爱图梅瓶',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts01'
|
|
|
|
|
- }, {
|
|
|
|
|
- name: '“太阳人”石刻',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts02'
|
|
|
|
|
- }, {
|
|
|
|
|
- name: '铜钺',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts03'
|
|
|
|
|
- }],
|
|
|
|
|
- pic2: [{
|
|
|
|
|
- name: '《甘绩熙自述》',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts04'
|
|
|
|
|
- }, {
|
|
|
|
|
- name: '起义军占领武昌后制发的出入城门证',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts05'
|
|
|
|
|
- }, {
|
|
|
|
|
- name: '王汉烈士画像',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts06'
|
|
|
|
|
- }],
|
|
|
|
|
- pic3: [{
|
|
|
|
|
- name: '战争年代李先念使用过的怀表',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts07'
|
|
|
|
|
- }, {
|
|
|
|
|
- name: '郭天民1955年荣获的八一、解放、独立一级勋章',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts08'
|
|
|
|
|
- }, {
|
|
|
|
|
- name: '123',
|
|
|
|
|
- link: 'https://4dscene.4dage.com/culturalrelics/HBSBWG-TS/Model2.html?m=hbts09'
|
|
|
|
|
- }],
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div
|
|
<div
|
|
@@ -79,9 +49,9 @@ const FlipPic = ({ activeIndex }: { activeIndex: number }) => {
|
|
|
className={`${styles.flipPic} ${isAnimating ? 'active' : ''}`}
|
|
className={`${styles.flipPic} ${isAnimating ? 'active' : ''}`}
|
|
|
>
|
|
>
|
|
|
{[1, 2, 3].map((i) => (
|
|
{[1, 2, 3].map((i) => (
|
|
|
- <div className={`picBox picBox${i}`} key={`bg${i}-${activeIndex}`} onClick={() => window.open(title[`pic${displayIndex + 1}`][i - 1].link)}>
|
|
|
|
|
- <div className="title">●{title[`pic${displayIndex + 1}`][i - 1].name as any}</div>
|
|
|
|
|
- <div className='pic'>
|
|
|
|
|
|
|
+ <div className={`picBox picBox${i}`} key={`bg${i}-${activeIndex}`}>
|
|
|
|
|
+ <div className="title">●{titleData[`pic${displayIndex + 1}`][i - 1].name as any}</div>
|
|
|
|
|
+ <div className='pic' onClick={() => setCurrentData(titleData[`pic${displayIndex + 1}`][i - 1])}>
|
|
|
<img
|
|
<img
|
|
|
className='front'
|
|
className='front'
|
|
|
src={require(`../../image/caro${isForward // 使用存储的方向状态
|
|
src={require(`../../image/caro${isForward // 使用存储的方向状态
|