From 8149a01e5a43a6ebe3ee645eaa4c646ea972ce8a Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Wed, 29 Apr 2026 16:07:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=88=E6=9B=B4=E6=96=B0=E4=B8=94?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B7=AF=E7=94=B1=E8=B7=B3=E8=BD=AC=E5=B9=B6?= =?UTF-8?q?=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/2026/information/index.jsx | 45 ++++++++++++++++++--------- src/pages/2026/information/index.less | 11 +++++-- src/pages/2026/train/index.jsx | 2 +- 3 files changed, 40 insertions(+), 18 deletions(-) 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" &&
开源大赛官方培训即将开启,助你冲刺奖项
+官方培训预告实时更新,助你冲刺
往期精彩与资料,尽在【赛事动态 - 赛事解读】板块