diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index 96d88e5..674c236 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -16,9 +16,11 @@ import HeritageCard from '@components/HeritageCard' import InheritorCard from '@components/InheritorCard' import { getStatistics, - getFeaturedHeritage, - getFeaturedInheritors, } from '@services/api' +import { getFeaturedHeritageList } from '@services/heritageApi' +import { getFeaturedInheritorList } from '@services/inheritorApi' +import { transformHeritageListItem } from '@utils/heritageTransform' +import { transformInheritorListItem } from '@utils/inheritorTransform' import type { HeritageItem, Inheritor, Statistics } from '@types/index' import './index.css' @@ -62,14 +64,15 @@ const Home: React.FC = () => { useEffect(() => { const fetchData = async () => { try { - const [stats, heritage, inheritors] = await Promise.all([ + const [stats, heritageList, inheritorList] = await Promise.all([ getStatistics(), - getFeaturedHeritage(6), - getFeaturedInheritors(4), + getFeaturedHeritageList(6), + getFeaturedInheritorList(4), ]) setStatistics(stats) - setFeaturedHeritage(heritage) - setFeaturedInheritors(inheritors) + // 转换后端数据为前端格式 + setFeaturedHeritage(heritageList.map(transformHeritageListItem)) + setFeaturedInheritors(inheritorList.map(transformInheritorListItem)) } catch (error) { console.error('Failed to fetch data:', error) } finally { diff --git a/src/router/index.tsx b/src/router/index.tsx index 740c464..973b89f 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -15,7 +15,7 @@ import NewsDetail from '@pages/News/Detail' import EventDetail from '@pages/News/EventDetail' import Login from '@pages/User/Login' import Register from '@pages/User/Register' -import UserCenter from '@pages/User/Center' +import UserCenter from '@pages/User/CenterNew' import SearchPage from '@pages/Search' import DataVisualization from '@pages/Data' import About from '@pages/About'