Merge pull request '动态设置专区新闻详情页、资源详情页页面title、head' (#580) from Eeeros/forgeplus-react:gitlink_server into gitlink_server

1
This commit is contained in:
Eeeros 2023-09-21 14:44:57 +08:00
commit 9fdfb2a75a
4 changed files with 38 additions and 3 deletions

View File

@ -7,7 +7,7 @@ export {
getImageUrl as getImageUrl,getImageUrlAbsolute as getImageUrlAbsolute,getImage as getImage, getmyUrl as getmyUrl, getRandomNumber as getRandomNumber, getUrl as getUrl, getZoneUrl as getZoneUrl, publicSearchs as publicSearchs, getRandomcode as getRandomcode, getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl
, getUploadActionUrl as getUploadActionUrl, getUploadActionUrltwo as getUploadActionUrltwo, getUploadActionUrlthree as getUploadActionUrlthree, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth
, getTaskUrlById as getTaskUrlById, TEST_HOST, htmlEncode as htmlEncode, getupload_git_file as getupload_git_file, getcdnImageUrl as getcdnImageUrl,
turnbar,returnbar,setSeoMeta as setSeoMeta , IsPC as IsPC
turnbar,returnbar,setSeoMeta as setSeoMeta , IsPC as IsPC, addMeta as addMeta
} from './UrlTool';
export { setmiyah as setmiyah } from './Component';

View File

@ -7,7 +7,7 @@ import { getNewsDetail } from '../api';
import { IsPC } from 'educoder';
import { tempConfig } from '../tempInfo';
import Acce from '../Component/mobile/accessory';
import { addMeta, setSeoMeta } from 'educoder';
function NewsDetail(props){
@ -44,6 +44,21 @@ 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() {
document.title= zonedetail.name;
setSeoMeta(`${zonedetail.name},`, zonedetail.name, zonedetail.subTitle, `/zone/${deptId}`)
}
function getDetails(){
setIsSpin(true)
getNewsDetail(id).then(result=>{

View File

@ -9,11 +9,13 @@ import { Base64 } from 'js-base64';
import { httpUrl } from '../fetch';
import { AlignCenter, FlexAJ } from '../../Component/layout';
import SourceIcon from '../img/sourceIcon.png';
import { addMeta, setSeoMeta } from 'educoder';
function SourceDetail(props){
const { deptId , sourceid } = props.match.params;
const [ detail , setDetail ] = useState(undefined);
const zonedetail = props.data;
useEffect(()=>{
if(sourceid){
@ -21,6 +23,21 @@ function SourceDetail(props){
}
},[sourceid])
useEffect(()=>{
//
if(detail){
const { name, domainName, summary} = detail;
document.title = `${ name }/${ domainName }`;
addMeta('Keywords', `${ name },${ domainName },${ summary }`);
}
return componentWillUnmount
}, [detail])
function componentWillUnmount() {
document.title= zonedetail.name;
setSeoMeta(`${zonedetail.name},`, zonedetail.name, zonedetail.subTitle, `/zone/${deptId}`)
}
function getDetails(){
getSourceDetail(sourceid).then(response=>{
if(response){

View File

@ -16,6 +16,8 @@ import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";
import { tempEnum } from "./tempInfo";
import { ImageLayerOfCommentHOC } from "../../modules/page/layers/ImageLayerOfCommentHOC";
import { setSeoMeta } from 'educoder';
const SourceDetail = Loadable({
loader: () => import("./Pages/sourceDetail"),
@ -127,6 +129,7 @@ function Index(props){
getAdminUrl(data.id);
getRole(data.id)
}
setSeoMeta(`${data.name},`, data.name, data.subTitle, `/zone/${deptId}`)
}
}).catch(console.error())
}
@ -204,7 +207,7 @@ function Index(props){
<Route
path="/zone/:deptId/source/:sourceid"
render={(p) => (
<SourceDetail {...props} {...p} id={id} temp={ temp }/>
<SourceDetail {...props} {...p} id={id} temp={ temp } data={data}/>
)}
></Route>
<Route