feat: 优化首页和路由配置
- 改进首页数据展示和布局 - 完善路由配置和页面导航 - 优化页面加载和性能
This commit is contained in:
parent
8f603837a1
commit
ffd849b87c
@ -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 {
|
||||
|
||||
@ -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'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user