diff --git a/src/pages/2026/information/index.jsx b/src/pages/2026/information/index.jsx index bedf5442b..15cb1ead1 100644 --- a/src/pages/2026/information/index.jsx +++ b/src/pages/2026/information/index.jsx @@ -4,7 +4,7 @@ import { useState , useEffect } from 'react'; import { information } from '../info'; import { getDocList } from '../api' import "../home/index.less"; -import { useModel , Link } from 'umi'; +import { useModel , Link , useLocation } from 'umi'; import SpeTitle from '../components/Title'; import Infoleftbanner from '../img/infoleftbanner.png'; import Resource from '../img/resource.png'; @@ -22,6 +22,21 @@ function Information() { const[ title ,setTitle] = useState(undefined); const[ searchTitle ,setSearchTitle] = useState(undefined); const [ showNews , setShowNews] = useState(false); + let { hash } = useLocation(); + + useEffect(() => { + if (hash) { + setTimeout(()=>{ + const element = document.getElementById(hash.slice(1)); + if (element) { + // 考虑固定头部的偏移 + const headerHeight = document.querySelector('header')?.offsetHeight || 64; + const elementTop = element.getBoundingClientRect().top + headerHeight; + window.scrollTo({ top: elementTop, behavior: 'smooth' }); + } + },200); + } + }, [hash]); function saishiNewActive(){ const observer = new IntersectionObserver((entries) => { @@ -104,18 +119,20 @@ function Information() { const getList = (id, name,title) => { return new Promise((resolve, reject) => { getDocList(id).then(res => { - let list = res.rows; - list = title ? list.filter(i=>i.name.indexOf(title)>-1 || i.summary.indexOf(title)>-1) : list; - list.forEach(e => { - if (e.publishTime) { - let time = e.publishTime.split('/'); - e.date1 = `${time[0]}年${time[1]}月`; - e.date2 = `${time[2]}日`; - } else { - e.date1 = e.date2 = '-' - } - }) - resolve({ name, list: list }); + if(res){ + let list = res.rows; + list = title ? list.filter(i=>i.name.indexOf(title)>-1 || i.summary.indexOf(title)>-1) : list; + list.forEach(e => { + if (e.publishTime) { + let time = e.publishTime.split('/'); + e.date1 = `${time[0]}年${time[1]}月`; + e.date2 = `${time[2]}日`; + } else { + e.date1 = e.date2 = '-' + } + }) + resolve({ name, list: list }); + } }) }) } @@ -227,7 +244,7 @@ function Information() { { information.category.map((e) => { return e.anchor === "guide" &&
开源大赛官方培训即将开启,助你冲刺奖项
+官方培训预告实时更新,助你冲刺
往期精彩与资料,尽在【赛事动态 - 赛事解读】板块