53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import React, { useEffect, useState } from "react";
|
|
import axios from "axios";
|
|
import AuthorItem from './Component/AuthorItem';
|
|
import BestModalItem from './Component/BestModalItem';
|
|
import Announcement from './Component/Announcement';
|
|
|
|
export default (({ plateId , operation })=> {
|
|
const [content, setContent] = useState(undefined);//公告
|
|
const [ recommand , setRecommand ]= useState(undefined);//推荐版块
|
|
const [ author , setAuthor ]= useState(undefined);//推荐作者
|
|
|
|
useEffect(()=>{
|
|
async function Init(){
|
|
const url = `/memos/forum_memos_right/${plateId}.json`;
|
|
axios.get(url).then(result=>{
|
|
if(result){
|
|
setContent({notice:result.data.notice,login:result.data.user_login,name:result.data.username});
|
|
setRecommand(result.data.recommend_forum_sections);
|
|
setAuthor(result.data.active_users);
|
|
}
|
|
}).catch(error=>{
|
|
console.log(error);
|
|
})
|
|
}
|
|
if(plateId){
|
|
Init();
|
|
}
|
|
},[plateId])
|
|
|
|
return (
|
|
<React.Fragment>
|
|
{
|
|
content &&
|
|
<div style={{ marginTop: "20px" }}>
|
|
<Announcement plateId={plateId} content={content} operation={operation}/>
|
|
</div>
|
|
}
|
|
{
|
|
author && author.length > 0 &&
|
|
<div style={{ marginTop: "20px" }}>
|
|
<AuthorItem author={author}/>
|
|
</div>
|
|
}
|
|
{
|
|
recommand && recommand.length > 0 &&
|
|
<div style={{ marginTop: "20px" }}>
|
|
<BestModalItem recommand={recommand}/>
|
|
</div>
|
|
}
|
|
</React.Fragment>
|
|
);
|
|
});
|