From b28f5a8be622edeb3d581ce8194933968353c134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=83=E5=AE=87?= Date: Wed, 20 Sep 2023 16:04:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=BF=AE=E6=94=B9=E4=B8=93?= =?UTF-8?q?=E5=8C=BA=E8=B5=84=E6=BA=90=E3=80=81=E6=96=B0=E9=97=BB=E7=9A=84?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2title=E3=80=81head?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/educoder.js | 2 +- src/forge/Information/Pages/newsDetail.jsx | 17 ++++++++++++++++- src/forge/Information/Pages/sourceDetail.jsx | 17 +++++++++++++++++ src/forge/Information/index.jsx | 6 ++++-- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/common/educoder.js b/src/common/educoder.js index 7b14824a..6575c503 100644 --- a/src/common/educoder.js +++ b/src/common/educoder.js @@ -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'; diff --git a/src/forge/Information/Pages/newsDetail.jsx b/src/forge/Information/Pages/newsDetail.jsx index 50e58767..b98da833 100644 --- a/src/forge/Information/Pages/newsDetail.jsx +++ b/src/forge/Information/Pages/newsDetail.jsx @@ -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=>{ diff --git a/src/forge/Information/Pages/sourceDetail.jsx b/src/forge/Information/Pages/sourceDetail.jsx index d94f8536..9b06fa4c 100644 --- a/src/forge/Information/Pages/sourceDetail.jsx +++ b/src/forge/Information/Pages/sourceDetail.jsx @@ -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){ diff --git a/src/forge/Information/index.jsx b/src/forge/Information/index.jsx index f775fc9f..4d58c75a 100644 --- a/src/forge/Information/index.jsx +++ b/src/forge/Information/index.jsx @@ -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"), @@ -108,6 +110,7 @@ function Index(props){ if(data.id){ getAdminUrl(data.id); } + setSeoMeta(`${data.name},`, data.name, data.subTitle, `/zone/${deptId}`) } }).catch(console.error()) } @@ -121,7 +124,6 @@ function Index(props){ } }).catch(error=>{}) } - console.log(deptId) return(
{ !sourcedetail && (id ? :
)} @@ -141,7 +143,7 @@ function Index(props){ ( - + )} >