|
|
@@ -1,5 +1,6 @@
|
|
|
import React, { useState, useRef } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
+import { isMobileFu } from '@/utils/history'
|
|
|
import { Swiper, SwiperSlide } from 'swiper/react'
|
|
|
|
|
|
import 'swiper/css'
|
|
|
@@ -8,7 +9,13 @@ import 'swiper/css/pagination'
|
|
|
import 'swiper/css/navigation'
|
|
|
|
|
|
import { EffectCoverflow, Pagination, Navigation } from 'swiper/modules'
|
|
|
-function Look({ style, setIsHideSider }: { style: React.CSSProperties; setIsHideSider: (isHideSider: boolean) => void }) {
|
|
|
+function Look({
|
|
|
+ style,
|
|
|
+ setIsHideSider
|
|
|
+}: {
|
|
|
+ style: React.CSSProperties
|
|
|
+ setIsHideSider: (isHideSider: boolean) => void
|
|
|
+}) {
|
|
|
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null)
|
|
|
const [selectIndex, setSelectIndex] = useState<number | null>(null)
|
|
|
const swiperRef = useRef<any>(null)
|
|
|
@@ -24,18 +31,22 @@ function Look({ style, setIsHideSider }: { style: React.CSSProperties; setIsHide
|
|
|
if (!document.fullscreenElement) {
|
|
|
// 直接请求iframe元素全屏(而非内部文档)
|
|
|
if (iframe.requestFullscreen) {
|
|
|
- iframe.requestFullscreen().then(() => {
|
|
|
- }).catch(err => {
|
|
|
- console.error('进入全屏失败:', err)
|
|
|
- })
|
|
|
+ iframe
|
|
|
+ .requestFullscreen()
|
|
|
+ .then(() => { })
|
|
|
+ .catch(err => {
|
|
|
+ console.error('进入全屏失败:', err)
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
// 退出全屏
|
|
|
if (document.exitFullscreen) {
|
|
|
- document.exitFullscreen().then(() => {
|
|
|
- }).catch(err => {
|
|
|
- console.error('退出全屏失败:', err)
|
|
|
- })
|
|
|
+ document
|
|
|
+ .exitFullscreen()
|
|
|
+ .then(() => { })
|
|
|
+ .catch(err => {
|
|
|
+ console.error('退出全屏失败:', err)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -52,70 +63,91 @@ function Look({ style, setIsHideSider }: { style: React.CSSProperties; setIsHide
|
|
|
{selectIndex === null ? (
|
|
|
<div className='content'>
|
|
|
{/* 移动端 */}
|
|
|
- <Swiper
|
|
|
- ref={swiperRef}
|
|
|
- loopPreventsSliding={false}
|
|
|
- effect={'coverflow'}
|
|
|
- grabCursor={true}
|
|
|
- centeredSlides={true}
|
|
|
- slidesPerView={'1'}
|
|
|
- coverflowEffect={{
|
|
|
- rotate: 0,
|
|
|
- stretch: 0,
|
|
|
- depth: 180,
|
|
|
- modifier: 4,
|
|
|
- }}
|
|
|
- pagination={{ el: '.swiper-pagination', clickable: true }}
|
|
|
- modules={[EffectCoverflow, Pagination, Navigation]}
|
|
|
- className='swiper_container'
|
|
|
- // onTransitionEnd={(swiper: unknown) => {
|
|
|
- // const swiperInternal = swiper as { loopFix: () => void }
|
|
|
- // swiperInternal.loopFix()
|
|
|
- // }}
|
|
|
- >
|
|
|
- {oreData.map((item: any, index: any) => (
|
|
|
- <SwiperSlide key={index}>
|
|
|
- <div
|
|
|
- className='itemCard'
|
|
|
- key={index}
|
|
|
- // onMouseEnter={() => setHoveredIndex(index)}
|
|
|
- // onMouseLeave={() => setHoveredIndex(null)}
|
|
|
- onClick={() => { setSelectIndex(index); setIsHideSider(true) }}
|
|
|
- >
|
|
|
- <div className='itemImage'>
|
|
|
- <img
|
|
|
- src={hoveredIndex === index ? item.activeImg : item.img}
|
|
|
- alt={item.title}
|
|
|
- />
|
|
|
+ {isMobileFu() && (
|
|
|
+ <Swiper
|
|
|
+ ref={swiperRef}
|
|
|
+ loopPreventsSliding={false}
|
|
|
+ effect={'coverflow'}
|
|
|
+ grabCursor={true}
|
|
|
+ centeredSlides={true}
|
|
|
+ slidesPerView={'1'}
|
|
|
+ coverflowEffect={{
|
|
|
+ rotate: 0,
|
|
|
+ stretch: 0,
|
|
|
+ depth: 180,
|
|
|
+ modifier: 4
|
|
|
+ }}
|
|
|
+ pagination={{ el: '.swiper-pagination', clickable: true }}
|
|
|
+ modules={[EffectCoverflow, Pagination, Navigation]}
|
|
|
+ className='swiper_container'
|
|
|
+ // 添加Swiper尺寸观察器
|
|
|
+ observer={true}
|
|
|
+ observeParents={true}
|
|
|
+ // 初始化后强制更新布局
|
|
|
+ onInit={(swiper: any) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ swiper.update()
|
|
|
+ }, 0)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {/* 保持原有的slide渲染代码不变 */}
|
|
|
+ {oreData.map((item, index) => (
|
|
|
+ <SwiperSlide key={index}>
|
|
|
+ <div
|
|
|
+ className='itemCard'
|
|
|
+ key={index}
|
|
|
+ // onMouseEnter={() => setHoveredIndex(index)}
|
|
|
+ // onMouseLeave={() => setHoveredIndex(null)}
|
|
|
+ onClick={() => {
|
|
|
+ setSelectIndex(index)
|
|
|
+ setIsHideSider(true)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div className='itemImage'>
|
|
|
+ <img
|
|
|
+ src={hoveredIndex === index ? item.activeImg : item.img}
|
|
|
+ alt={item.title}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className='viewButton'>查看详情</div>
|
|
|
</div>
|
|
|
- <div className='viewButton'>查看详情</div>
|
|
|
- </div>
|
|
|
- </SwiperSlide>
|
|
|
- ))}
|
|
|
- </Swiper>
|
|
|
+ </SwiperSlide>
|
|
|
+ ))}
|
|
|
+ </Swiper>
|
|
|
+ )}
|
|
|
|
|
|
{/* pc端 */}
|
|
|
- {oreData.map((item: any, index: any) => (
|
|
|
- <div
|
|
|
- className='itemCard pcItem'
|
|
|
- key={index}
|
|
|
- onMouseEnter={() => setHoveredIndex(index)}
|
|
|
- onMouseLeave={() => setHoveredIndex(null)}
|
|
|
- onClick={() => { setSelectIndex(index); setIsHideSider(true) }}
|
|
|
- >
|
|
|
- <div className='itemImage'>
|
|
|
- <img
|
|
|
- src={hoveredIndex === index ? item.activeImg : item.img}
|
|
|
- alt={item.title}
|
|
|
- />
|
|
|
+ {!isMobileFu() &&
|
|
|
+ oreData.map((item, index) => (
|
|
|
+ <div
|
|
|
+ className='itemCard pcItem'
|
|
|
+ key={index}
|
|
|
+ onMouseEnter={() => setHoveredIndex(index)}
|
|
|
+ onMouseLeave={() => setHoveredIndex(null)}
|
|
|
+ onClick={() => {
|
|
|
+ setSelectIndex(index)
|
|
|
+ setIsHideSider(true)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div className='itemImage'>
|
|
|
+ <img
|
|
|
+ src={hoveredIndex === index ? item.activeImg : item.img}
|
|
|
+ alt={item.title}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className='viewButton'>查看详情</div>
|
|
|
</div>
|
|
|
- <div className='viewButton'>查看详情</div>
|
|
|
- </div>
|
|
|
- ))}
|
|
|
+ ))}
|
|
|
</div>
|
|
|
) : (
|
|
|
<>
|
|
|
- <div className='back' onClick={() => { setSelectIndex(null); setIsHideSider(false) }}>
|
|
|
+ <div
|
|
|
+ className='back'
|
|
|
+ onClick={() => {
|
|
|
+ setSelectIndex(null)
|
|
|
+ setIsHideSider(false)
|
|
|
+ }}
|
|
|
+ >
|
|
|
<img src={require('@/assets/img/back.png')} alt='' />
|
|
|
</div>
|
|
|
|