Commit 752eb31e authored by mxm-web-develop's avatar mxm-web-develop

Merge branch 'main' of gitlab.33.cn:Website/web2022

parents 7fe9ae14 ef196d79
...@@ -34,11 +34,11 @@ const AppReducer = (state:typeof data,action:Actions)=>{ ...@@ -34,11 +34,11 @@ const AppReducer = (state:typeof data,action:Actions)=>{
} }
return {...state} return {...state}
} }
export const resizeOb = fromEvent(window,'resize')
export const AppProvider = (props: any)=>{ export const AppProvider = (props: any)=>{
const [state,dispatch] = useReducer(AppReducer,data) const [state,dispatch] = useReducer(AppReducer,data)
const location = useLocation() const location = useLocation()
const ob = fromEvent(window,'resize')
useEffect(()=>{ useEffect(()=>{
dispatch({type:'routerOnChange',payload:{currentPage:location.pathname}}) dispatch({type:'routerOnChange',payload:{currentPage:location.pathname}})
dispatch({type:'slideOnChange',payload:{pageIndex:0}}) dispatch({type:'slideOnChange',payload:{pageIndex:0}})
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
useInteractions, useInteractions,
useHover, useHover,
} from "@floating-ui/react-dom-interactions"; } from "@floating-ui/react-dom-interactions";
import {resizeOb} from "@/store/AppProvider";
interface EventItemType extends IProps { interface EventItemType extends IProps {
itmeIndex: number; itmeIndex: number;
data: any; data: any;
...@@ -86,7 +87,7 @@ export const EventItem = (props: EventItemType) => { ...@@ -86,7 +87,7 @@ export const EventItem = (props: EventItemType) => {
export const EventCols = (props: EventColsType) => { export const EventCols = (props: EventColsType) => {
const { data } = props; const { data } = props;
return ( return (
<div className="grid grid-cols-4 pb-[3rem]"> <div className="grid grid-cols-4 labtop:grid-cols-5 pb-[3rem]">
{data && {data &&
data.length > 0 && data.length > 0 &&
data.map((i: any, index: number) => ( data.map((i: any, index: number) => (
...@@ -96,14 +97,27 @@ export const EventCols = (props: EventColsType) => { ...@@ -96,14 +97,27 @@ export const EventCols = (props: EventColsType) => {
); );
}; };
const checkWidth=(width:number)=>{
return width>=1920
}
export const EventsTable = (props: EventsTableType) => { export const EventsTable = (props: EventsTableType) => {
const { tableIndex, data } = props; const { tableIndex, data } = props;
const [colData, setColData] = useState<undefined | any[]>(undefined); const [colData, setColData] = useState<undefined | any[]>(undefined);
useEffect(() => { const setData=(width:number)=>{
const half = 4; let half=4
if(checkWidth(width)){
half=5
}
const c = _chunk(data, half); const c = _chunk(data, half);
setColData(c); setColData(c);
}
useEffect(() => {
resizeOb.subscribe((event)=>{
//@ts-ignore
setData(event.currentTarget?.innerWidth)
})
setData(window.innerWidth)
// setData(4);
}, [data]); }, [data]);
return ( return (
<div> <div>
......
...@@ -7,18 +7,36 @@ import { EventItem, EventsTable } from "./EventItem" ...@@ -7,18 +7,36 @@ import { EventItem, EventsTable } from "./EventItem"
import { EventsScrollView } from "@/components/EventsScrollView" import { EventsScrollView } from "@/components/EventsScrollView"
import Step from "@/assets/img/step.png" import Step from "@/assets/img/step.png"
import {resizeOb} from "@/store/AppProvider";
interface MemorabiliaType extends IProps { interface MemorabiliaType extends IProps {
} }
const checkWidth=(width:number)=>{
return width>=1920
}
export const Memorabilia = () => { export const Memorabilia = () => {
const [data,setData] = useState<any>() const [data,setData] = useState<any>()
const [currentSlide,setCurrentSlide] = useState(0) const [currentSlide,setCurrentSlide] = useState(0)
useEffect(()=>{ useEffect(()=>{
const fetchData = getEvents(8).subscribe(v=>{ let fetchNum=8,fetchData:any=null;
resizeOb.subscribe((event)=>{
//@ts-ignore
const _fetchNum=checkWidth(event.currentTarget.innerWidth)?10:8
if(_fetchNum!==fetchNum){
fetchNum=_fetchNum
setData(data.slice(0,8))
fetchData = getEvents(_fetchNum).subscribe(v=>{
setData(v)
},err=>{ throw new Error(err)})
}
})
fetchData = getEvents(checkWidth(window.innerWidth)?10:8).subscribe(v=>{
setData(v) setData(v)
},err=>{ throw new Error(err)}) },err=>{ throw new Error(err)})
return ()=> fetchData.unsubscribe() return ()=> fetchData.unsubscribe()
...@@ -45,10 +63,10 @@ export const Memorabilia = () => { ...@@ -45,10 +63,10 @@ export const Memorabilia = () => {
} }
return ( return (
<AppContianer className="flex items-center justify-start h-full w-full relative labtop:px-[120px] "> <AppContianer className="flex items-center justify-start h-full w-full labtop:px-[120px] ">
<div className='w-[896px]'> <div className='w-[896px] labtop:w-[1120px] min-h-[750px] relative '>
<div className='absolute top-12 labtop:right-[14rem] right-[7rem]'> <div className='absolute top-12 right-0 translate-x-[100%]'>
<div className="hero-title">Memorabilia</div> <div className="hero-title">Memorabilia</div>
<div className="subTitle-1-cn py-3 flex items-center gap-x-5"> <div className="subTitle-1-cn py-3 flex items-center gap-x-5">
<div className=" w-28 h-1 bg-theme-dark rounded"></div> <div className=" w-28 h-1 bg-theme-dark rounded"></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment