首页顶部新闻改为从专区(CCF)获取

This commit is contained in:
caishi 2024-07-12 16:25:23 +08:00
parent f7b79a18a0
commit c2737ee9d6
1 changed files with 17 additions and 3 deletions

View File

@ -10,11 +10,14 @@ import F44 from './Img/4-4.png';
import SecondEdition from './SecondEdition';
import FifthEdition from './FifthEdition';
import { TPMIndexHOC } from '../modules/tpm/TPMIndexHOC';
import Axios from 'axios';
const ZoneInfo = {id:4,identify:"CCF-ODC",httpUrl:"https://gateway.gitlink.org.cn"}
function Index(props) {
const [ value , setValue ] = useState("");
const [ flag , setFlag ] = useState(true);
const pathname = props.history.location;
const [ bannerTab , setBannerTab ] = useState(undefined);
const register = props && props.mygetHelmetapi && props.mygetHelmetapi.common && props.mygetHelmetapi.common.register;
@ -23,7 +26,8 @@ function Index(props) {
useEffect(()=>{
window.addEventListener("scroll",scrollListener);
getTab();
// getTab();
getNewsList();
return ComponentWillUnmount;
},[])
@ -35,6 +39,16 @@ function Index(props) {
window.removeEventListener("scroll",scrollListener);
}
function getNewsList(){
const url = `${ZoneInfo.httpUrl}/api/cms/doc/open/zone/${ZoneInfo.id}/homePageDocList`;
Axios.get(url).then(result=>{
if(result){
let rows = result.data.rows;
setBannerTab(rows);
}
}).catch(error=>{})
}
function getTab() {
const url = `/topics.json?topic_type=card`;
Axios.get(url,{
@ -83,9 +97,9 @@ function Index(props) {
{
bannerTab.map((i,k)=>{
return(
<a href={i.url} target="_blank" className="font-18">
k < 3 && <a href={`${!window.location.hostname.indexOf("gitlink.org.cn")>-1 ? "https://www.gitlink.org.cn":""}/zone/${ZoneInfo.identify}/newdetail/${i.id}`} target="_blank" className="font-18">
<li>
{i.title}
{i.name}
</li>
</a>
)