This commit is contained in:
zhangjianjun 2026-04-15 10:24:02 +08:00
parent 29516c9a1e
commit cc85c497c9
8 changed files with 33 additions and 27 deletions

View File

@ -45,8 +45,8 @@ export default function RowAccordion({ data, placement='bottom' }: Props) {
} }
}, [isInView]); }, [isInView]);
const getToPath = (link: { text: string; path: string }) => { const getToPath = (link: { text: string; path: string }, index: number) => {
return link.path.includes("{id}") ? link.path.replace("{id}", link.text) : link.path; return link.path.includes("{id}") ? link.path.replace("{id}", index.toString()) : link.path;
} }
return ( return (
@ -98,8 +98,8 @@ export default function RowAccordion({ data, placement='bottom' }: Props) {
)} )}
{item.links && ( {item.links && (
<div className={styles.contentItemLinks}> <div className={styles.contentItemLinks}>
{item.links?.map((link) => ( {item.links?.map((link, index) => (
<Link key={link.text} to={getToPath(link)}>{link.text}</Link> <Link key={link.text} to={getToPath(link, index)}>{link.text}</Link>
))} ))}
</div> </div>
)} )}

View File

@ -33,14 +33,14 @@ export default function SwiperCardSection({ data, disableHover=false }: { data:
useEffect(() => { useEffect(() => {
if (hashId && data.cardItems && swiperRef) { if (hashId && data.cardItems && swiperRef) {
const index = data.cardItems.findIndex((item) => item.title === hashId); const index = data.cardItems.findIndex((item, index) => index == parseInt(hashId));
if (index !== -1) { if (index !== -1) {
swiperRef.slideTo(index, 0); swiperRef.slideTo(index, 0);
} }
} }
}, [hashId, data.cardItems, swiperRef]) }, [hashId, data.cardItems, swiperRef])
return ( return (
<section className={styles.swiperCardSection} id={data.cardItems[activeIndex]?.title} style={{ backgroundImage: `url(${data.backgroundImage})` }}> <section className={styles.swiperCardSection} id={location.key + hashId} style={{ backgroundImage: `url(${data.backgroundImage})` }}>
<SectionTitle title={data.title} /> <SectionTitle title={data.title} />
<div className={styles.carouselWrapper} > <div className={styles.carouselWrapper} >
{activeIndex > 0 && ( {activeIndex > 0 && (

View File

@ -104,7 +104,6 @@ export default function TopTabs({ data, activeIndex, setActiveIndex, className }
useEffect(() => { useEffect(() => {
console.log('locale', locale);
updateIndicatorPosition(); updateIndicatorPosition();
}, [locale]); }, [locale]);

View File

@ -36,10 +36,9 @@ export default function TopTabsSection({ data, className }: { data: Data, classN
const hash = location.hash; const hash = location.hash;
const hashId = decodeURIComponent(hash.replace('#', '')); const hashId = decodeURIComponent(hash.replace('#', ''));
const [activeIndex, setActiveIndex] = useState(0); const [activeIndex, setActiveIndex] = useState(0);
useEffect(() => { useEffect(() => {
if (hashId && data.tabItems) { if (hashId && data.tabItems) {
const index = data.tabItems.findIndex((item) => item.tabName === hashId); const index = data.tabItems.findIndex((item, index) => index === parseInt(hashId));
if (index !== -1) { if (index !== -1) {
setActiveIndex(index); setActiveIndex(index);
} }
@ -49,10 +48,10 @@ export default function TopTabsSection({ data, className }: { data: Data, classN
const sideSlides = sideImageToSlides(data.tabItems[activeIndex]?.sideImage); const sideSlides = sideImageToSlides(data.tabItems[activeIndex]?.sideImage);
return ( return (
<section className={`${styles.topTabsSection} ${className}`} style={{ backgroundImage: `url(${data.backgroundImage})` }}> <section id={location.key + hashId} className={`${styles.topTabsSection} ${className}`} style={{ backgroundImage: `url(${data.backgroundImage})` }}>
<div aria-hidden="true"> <div aria-hidden="true">
{data.tabItems.map((item) => ( {data.tabItems.map((item,index) => (
<div key={item.tabName} id={item.tabName} style={{ height: 0, overflow: "hidden" }} /> <div key={item.tabName} style={{ height: 0, overflow: "hidden" }} />
))} ))}
</div> </div>
<TopTabs data={data} activeIndex={activeIndex} setActiveIndex={setActiveIndex} /> <TopTabs data={data} activeIndex={activeIndex} setActiveIndex={setActiveIndex} />

View File

@ -1,13 +1,16 @@
import { useEffect } from "react"; import { useEffect, useRef } from "react";
import { useLocation } from "react-router-dom"; import { useLocation, useNavigationType } from "react-router-dom";
import { scrollToWithLenis } from "@/utils/lenis"; import { scrollToWithLenis } from "@/utils/lenis";
const useHashScroll = () => { const useHashScroll = () => {
const location = useLocation(); const location = useLocation();
const navType = useNavigationType(); // POP / PUSH / REPLACE
useEffect(() => { useEffect(() => {
if (!location.hash) { if (!location.hash) {
scrollToWithLenis(0, { immediate: true }); if(navType === 'PUSH') {
scrollToWithLenis(0, { immediate: false });
}
return; return;
} }
@ -15,9 +18,10 @@ const useHashScroll = () => {
let attempts = 0; let attempts = 0;
const maxAttempts = 120; const maxAttempts = 120;
const targetId = decodeURIComponent(location.hash.slice(1)); const targetId = decodeURIComponent(location.hash.slice(1));
const tryScrollToHash = () => { const tryScrollToHash = () => {
const element = targetId ? document.getElementById(targetId) : null; const element = targetId ? document.getElementById(location.key + targetId) : null;
console.log('location.key + id', location.key + targetId)
console.log('element', element)
if (element) { if (element) {
const header = document.querySelector("header"); const header = document.querySelector("header");
const headerHeight = header?.getBoundingClientRect().height ?? 7.5 * 16; const headerHeight = header?.getBoundingClientRect().height ?? 7.5 * 16;
@ -34,9 +38,11 @@ const useHashScroll = () => {
} }
}; };
rafId = window.requestAnimationFrame(tryScrollToHash); setTimeout(() => {
rafId = window.requestAnimationFrame(tryScrollToHash);
},50)
return () => window.cancelAnimationFrame(rafId); return () => window.cancelAnimationFrame(rafId);
}, [location.pathname, location.hash]); }, [location.pathname, location.hash, navType]);
}; };
export default useHashScroll; export default useHashScroll;

View File

@ -10,7 +10,9 @@ export default function MainLayout() {
<div className="layout"> <div className="layout">
<Header /> <Header />
<main className="container"> <main className="container">
<KeepAliveRouteOutlet /> <KeepAliveRouteOutlet
exclude={[/^\/business\/base-group(?:\?.*)?$/, /^\/business\/commercial-group(.*)/]}
/>
</main> </main>
<Footer /> <Footer />
</div> </div>

View File

@ -13,9 +13,9 @@ export default function About() {
const banner = overview?.banner; const banner = overview?.banner;
const section1Data = overview?.section1Data?.items ?? []; const section1Data = overview?.section1Data?.items ?? [];
const getLinkPath = (item: any) => { const getLinkPath = (item: any, index: number) => {
if(item.path.includes("{id}")) { if(item.path.includes("{id}")) {
return item.path.replace("{id}", item.label); return item.path.replace("{id}", index.toString());
} }
return item.path; return item.path;
} }
@ -43,9 +43,9 @@ export default function About() {
<h2 className={styles.title}>{item.title}</h2> <h2 className={styles.title}>{item.title}</h2>
<p className={styles.desc}>{item.content}</p> <p className={styles.desc}>{item.content}</p>
<div className={styles.links}> <div className={styles.links}>
{item.links?.map((link: { label: string; path: string }) => ( {item.links?.map((link: { label: string; path: string }, index: number) => (
<span key={link.label}> <span key={link.label}>
<Link to={getLinkPath(link)}>{link.label}</Link> <Link to={getLinkPath(link, index)}>{link.label}</Link>
</span> </span>
))} ))}
</div> </div>

View File

@ -30,7 +30,7 @@ export default function InvestGroup() {
{section1Data && <ParagraphSection data={section1Data} />} {section1Data && <ParagraphSection data={section1Data} />}
{section2Data && ( {section2Data && (
<section className={styles.investGroup} id={section2Data.title} style={{ <section className={styles.investGroup} id={"0"} style={{
backgroundImage: `url(${section2Data.backgroundImage})` backgroundImage: `url(${section2Data.backgroundImage})`
}}> }}>
<div className={styles.investGroupInner}> <div className={styles.investGroupInner}>
@ -52,7 +52,7 @@ export default function InvestGroup() {
)} )}
{section3Data && ( {section3Data && (
<section className={styles.equityInvestment} id={section3Data.title} <section className={styles.equityInvestment} id={"1"}
style={{ style={{
backgroundImage: `url(${section3Data.backgroundImage})` backgroundImage: `url(${section3Data.backgroundImage})`
}} }}
@ -76,7 +76,7 @@ export default function InvestGroup() {
)} )}
{section4Data && ( {section4Data && (
<div id={section4Data.title}> <div id={"2"}>
<Section <Section
background={section4Data.backgroundImage} background={section4Data.backgroundImage}
maskBackground="rgba(20,53,92,0.1)" maskBackground="rgba(20,53,92,0.1)"