diff --git a/src/forge/Information/Pages/headerPage.jsx b/src/forge/Information/Pages/headerPage.jsx index 7ac2948c9..11711d107 100644 --- a/src/forge/Information/Pages/headerPage.jsx +++ b/src/forge/Information/Pages/headerPage.jsx @@ -4,7 +4,7 @@ import { httpUrl } from '../fetch'; import guideArrow from '../img/guideArrow.png'; import { Link } from 'react-router-dom'; import shijian from '../img/shijian.png'; -import { getHomePageList , gethomePageDocList , getAllList } from '../api'; +import { getHomePageList , gethomePageDocList , getAllList, getPartnerList } from '../api'; import axios from 'axios'; import Partner from '../Component/partner'; @@ -21,7 +21,7 @@ function HeaderPage(props){ getProjectList(); getNewsList(); getPersonList(); - getPartnerList(); + getPartner(); } },[id]) @@ -49,9 +49,8 @@ function HeaderPage(props){ }).catch(console.error()) } - function getPartnerList(){ - const url = `${httpUrl}/zone/open/${id}/partners/list`; - axios.get(url).then(result=>{ + function getPartner(){ + getPartnerList(id).then(result => { if(result){ const array = result.data.rows; const newArray = []; @@ -66,7 +65,7 @@ function HeaderPage(props){ } setParterList(newArray); } - }).catch(error=>{}) + }) } return(
diff --git a/src/forge/Information/Pages/headerPageZone1.jsx b/src/forge/Information/Pages/headerPageZone1.jsx index dc46b6508..c1893c61c 100644 --- a/src/forge/Information/Pages/headerPageZone1.jsx +++ b/src/forge/Information/Pages/headerPageZone1.jsx @@ -16,12 +16,12 @@ import ra from '../img/ra.png' import title from '../img/title.png' import { Link } from 'react-router-dom'; import shijian from '../img/shijian.png'; -import axios from 'axios'; import Nodata from '../../Nodata'; import Projects from '../Component/projects'; import Contributor from '../Component/contributor'; import Partner from '../Component/partner'; import '../indexZone1.scss' +import { getProjectsLists, getPartnerList, getHomePageList, gethomePageDocList } from '../api' function HeaderPage(props){ const [ projectList , setProjectList ] = useState(undefined); @@ -65,13 +65,12 @@ function HeaderPage(props){ getProjectList(); getNewsList(); getPersonList(); - getPartnerList(); + getPartner(); } },[id]) function getPersonList(){ - const url = `${httpUrl}/zone/open/${id}/member/homePageList`; - axios.get(url).then(result=>{ + getHomePageList(id).then(result=>{ if(result){ setPersonList(result.data.rows); } @@ -79,19 +78,14 @@ function HeaderPage(props){ } function getNewsList(){ - const url = `${httpUrl}/cms/doc/open/zone/${id}/homePageDocList`; - axios.get(url).then(result=>{ + gethomePageDocList(id).then(result=>{ if(result){ setNewsList(result.data.rows); } }).catch(error=>{}) } - function getProjectList(){ - const url = `${httpUrl}/zone/open/${id}/project/list`; - axios.get(url,{params:{ - isHomepage:1 - }}).then(result=>{ + getProjectsLists(id,{ isHomepage:1 }).then(result=>{ if(result){ if (result.data.rows.length < 3) { setProjectList(result.data.rows) @@ -99,12 +93,11 @@ function HeaderPage(props){ setProjectList([...result.data.rows, {}]); } } - }).catch(console.error()) + }).catch(error=>{}) } - function getPartnerList(){ - const url = `${httpUrl}/zone/open/${id}/partners/list`; - axios.get(url).then(result=>{ + function getPartner(){ + getPartnerList(id).then(result => { if(result){ const array = result.data.rows; const newArray = []; @@ -119,7 +112,7 @@ function HeaderPage(props){ } setParterList(newArray); } - }).catch(error=>{}) + }) } return(
diff --git a/src/forge/Information/Pages/newsCreate.jsx b/src/forge/Information/Pages/newsCreate.jsx index 5926af15d..24721d43a 100644 --- a/src/forge/Information/Pages/newsCreate.jsx +++ b/src/forge/Information/Pages/newsCreate.jsx @@ -22,6 +22,7 @@ function NewsCreate(props){ const [dirList, setDirList] = useState(undefined); const [loading, setLoading] = useState(false); const [isEdit, setIsEdit] = useState(false); + const { sectionCmsTitle } = props.data; const layout = { labelCol: { span: 2 }, wrapperCol: { span: 14 }, @@ -123,7 +124,7 @@ function NewsCreate(props){ return(
- {tempConfig[temp].mainTitle} + { sectionCmsTitle } {isEdit ? '编辑' : '新建'}文章
diff --git a/src/forge/Information/Pages/newsDetail.jsx b/src/forge/Information/Pages/newsDetail.jsx index ac736791a..713fe41ba 100644 --- a/src/forge/Information/Pages/newsDetail.jsx +++ b/src/forge/Information/Pages/newsDetail.jsx @@ -19,7 +19,7 @@ function NewsDetail(props){ const [ isSpin , setIsSpin]=useState(false); const [ commentReload, setCommentReload] = useState(undefined); const temp = props.temp; - const zonedetail = props.data; + const { zonedetail, sectionCmsTitle, mainTitle } = props.data; useEffect(()=>{ let initialContent = undefined; @@ -33,6 +33,7 @@ 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); } @@ -99,7 +100,7 @@ function NewsDetail(props){ { !IsPC() && - {tempConfig[temp].mainTitle} + { sectionCmsTitle } { cmsDir && {cmsDir.name} } 正文 diff --git a/src/forge/Information/Pages/selfList.jsx b/src/forge/Information/Pages/selfList.jsx index 74d11df27..76b888abd 100644 --- a/src/forge/Information/Pages/selfList.jsx +++ b/src/forge/Information/Pages/selfList.jsx @@ -22,6 +22,7 @@ function SelfList(props){ const pathname = props.location.pathname; const { deptId} = props.match.params; const { id , temp , data } = props; + const { sectionCmsTitle } = data; const limit = 15; useEffect(()=>{ @@ -142,7 +143,7 @@ function SelfList(props){
- {source ? "资源发布": temp === tempEnum.zone1 ? "新闻资讯":"领域资讯"} + { sectionCmsTitle } 我的{source ? "资源":"文章"}
    diff --git a/src/forge/Information/Pages/sourceDetail.jsx b/src/forge/Information/Pages/sourceDetail.jsx index eae707ff8..e9a181069 100644 --- a/src/forge/Information/Pages/sourceDetail.jsx +++ b/src/forge/Information/Pages/sourceDetail.jsx @@ -33,7 +33,7 @@ function SourceDetail(props){ function componentWillUnmount() { if (zonedetail) { - document.title= zonedetail.name; + document.title= zonedetail.mainTitle; setSeoMeta(`${zonedetail.name},`, zonedetail.name, zonedetail.subTitle, `/zone/${deptId}`) } } diff --git a/src/forge/Information/api.js b/src/forge/Information/api.js index fb4daeb67..c9cc48673 100644 --- a/src/forge/Information/api.js +++ b/src/forge/Information/api.js @@ -46,6 +46,13 @@ export function getAllList(id,params){ }) } +export function getPartnerList(id){ + return fetch({ + url:`/zone/open/${id}/partners/list`, + method: 'get', + }) +} + /**领域资讯 */ export function getNewsAllList(id,params){ return fetch({ diff --git a/src/forge/Information/fetch.js b/src/forge/Information/fetch.js index 29cc15d28..f74c1faef 100644 --- a/src/forge/Information/fetch.js +++ b/src/forge/Information/fetch.js @@ -5,11 +5,22 @@ function beforeFetch(actionUrl){ if (window.location.href.indexOf('localhost') < 0) { axios.defaults.withCredentials = true; } - - const service = axios.create({ + const config = { baseURL: actionUrl, timeout: 1800000, // 请求超时时间 - }); + } + + const service = axios.create(config); + + service.interceptors.request.use(request => { + let deptId = sessionStorage.getItem('deptId') + + if (deptId) { + // 用于权限区分 + request.headers['Dept-Id'] = deptId + } + return request + }) service.interceptors.response.use( response => { diff --git a/src/forge/Information/index.jsx b/src/forge/Information/index.jsx index cf14149ec..09f99b3b3 100644 --- a/src/forge/Information/index.jsx +++ b/src/forge/Information/index.jsx @@ -124,16 +124,18 @@ function Index(props){ return } let data = result.data.data; - if (data.template) { + if (data && data.template) { setTemp( data.template ) } setData(data); - document.title= data && data.name; + document.title= data && data.mainTitle; setId(data.id); if(data.id){ getAdminUrl(data.id); getRole(data.id) } + // 存储deptId,所有专区接口header带上 + sessionStorage.setItem('deptId', data.deptId) setSeoMeta(`${data.name},`, data.name, data.subTitle, `/zone/${deptId}`) } }).catch(console.error())