forked from Gitlink/forgeplus-react
兼容移动端
This commit is contained in:
parent
9568be9ce6
commit
b92acb7a35
|
|
@ -19,10 +19,16 @@ function NewsDetail(props){
|
|||
const [ isSpin , setIsSpin]=useState(false);
|
||||
const [ commentReload, setCommentReload] = useState(undefined);
|
||||
const temp = props.temp;
|
||||
const { zonedetail, sectionCmsTitle, mainTitle } = props.data;
|
||||
const zonedetail = props.data;
|
||||
|
||||
useEffect(()=>{
|
||||
let initialContent = undefined;
|
||||
// 设置网页标题
|
||||
if(detail){
|
||||
const { name, cmsDir, summary} = detail;
|
||||
document.title = `${ name }/${ cmsDir.name }`;
|
||||
addMeta('Keywords', `${ name },${ cmsDir.name },${ summary }`);
|
||||
}
|
||||
if(IsPC() && zonedetail){
|
||||
setTimeout(()=>{
|
||||
window.scrollTo(0,1);
|
||||
|
|
@ -33,10 +39,13 @@ function NewsDetail(props){
|
|||
document.querySelector('meta[name="viewport"]').setAttribute('content','width=device-width, user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0');
|
||||
}
|
||||
return()=>{
|
||||
document.title = mainTitle;
|
||||
if(IsPC()){
|
||||
document.querySelector('meta[name="viewport"]').setAttribute('content', initialContent);
|
||||
}
|
||||
if (zonedetail) {
|
||||
document.title= zonedetail.mainTitle;
|
||||
setSeoMeta(`${zonedetail.name},`, zonedetail.name, zonedetail.subTitle, `/zone/${deptId}`)
|
||||
}
|
||||
}
|
||||
},[zonedetail,detail])
|
||||
|
||||
|
|
@ -47,23 +56,6 @@ function NewsDetail(props){
|
|||
}
|
||||
},[id])
|
||||
|
||||
useEffect(()=>{
|
||||
// 设置网页标题
|
||||
if(detail){
|
||||
const { name, cmsDir, summary} = detail;
|
||||
document.title = `${ name }/${ cmsDir.name }`;
|
||||
addMeta('Keywords', `${ name },${ cmsDir.name },${ summary }`);
|
||||
}
|
||||
return componentWillUnmount
|
||||
}, [detail])
|
||||
|
||||
function componentWillUnmount() {
|
||||
if (zonedetail) {
|
||||
document.title= zonedetail.name;
|
||||
setSeoMeta(`${zonedetail.name},`, zonedetail.name, zonedetail.subTitle, `/zone/${deptId}`)
|
||||
}
|
||||
}
|
||||
|
||||
function getDetails(){
|
||||
setIsSpin(true)
|
||||
getNewsDetail(id).then(result=>{
|
||||
|
|
@ -100,7 +92,7 @@ function NewsDetail(props){
|
|||
{
|
||||
!IsPC() &&
|
||||
<Breadcrumb separator=">">
|
||||
<Breadcrumb.Item href={`/zone/${deptId}/news`}>{ sectionCmsTitle }</Breadcrumb.Item>
|
||||
<Breadcrumb.Item href={`/zone/${deptId}/news`}>{ zonedetail.sectionCmsTitle }</Breadcrumb.Item>
|
||||
{ cmsDir && <Breadcrumb.Item href={`/zone/${deptId}/news/${cmsDir.id}`}>{cmsDir.name}</Breadcrumb.Item> }
|
||||
<Breadcrumb.Item>正文</Breadcrumb.Item>
|
||||
</Breadcrumb>
|
||||
|
|
|
|||
Loading…
Reference in New Issue