设置服务端请求cookie
This commit is contained in:
parent
b6eb721620
commit
22eaa56f1a
|
@ -56,6 +56,15 @@ export const render = async (req,res)=>{
|
|||
|
||||
|
||||
if (_route && _route.component && _route.component.preFetch) {
|
||||
|
||||
// 设置服务端请求cookie
|
||||
let cookies = req.headers.cookie.split(';')
|
||||
for (let index = 0; index < cookies.length; index++) {
|
||||
const element = cookies[index];
|
||||
domObj.window.document.cookie = element
|
||||
}
|
||||
|
||||
|
||||
context = await _route.component.preFetch({
|
||||
store,
|
||||
match: _match,
|
||||
|
|
|
@ -308,8 +308,7 @@ class Detail extends Component {
|
|||
secondSync: false,
|
||||
mirror_status:0
|
||||
})
|
||||
// this.getBanner(this.props.projectMenu)
|
||||
this.getBanner()
|
||||
this.getBanner(this.props.projectMenu)
|
||||
let projectdata
|
||||
if (this.props.defaultDetail) {
|
||||
projectdata = this.props.defaultDetail
|
||||
|
|
|
@ -29,9 +29,9 @@ function ServerIndex(props){
|
|||
|
||||
useEffect(()=>{
|
||||
// 非项目协作者不可进入服务tab (3397)
|
||||
// if(projectDetail && projectDetail.permission === ""){
|
||||
// props.history.push(`/${owner}/${projectsId}`);
|
||||
// }
|
||||
if(projectDetail && projectDetail.permission === ""){
|
||||
props.history.push(`/${owner}/${projectsId}`);
|
||||
}
|
||||
}, [projectDetail])
|
||||
|
||||
return(
|
||||
|
|
|
@ -18,41 +18,65 @@ const axiosInstance = axios.create({
|
|||
//
|
||||
export async function getProjectFunc (owner, projectsId) {
|
||||
const url = `${baseUrl}/${owner}/${projectsId}/simple.json`;
|
||||
if (__SERVER__) {
|
||||
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
|
||||
}
|
||||
return axiosInstance.get(url);
|
||||
}
|
||||
|
||||
export async function getProjectDetailFunc (owner, projectsId) {
|
||||
const url = `${baseUrl}/${owner}/${projectsId}/detail.json`;
|
||||
if (__SERVER__) {
|
||||
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
|
||||
}
|
||||
return axiosInstance.get(url);
|
||||
}
|
||||
|
||||
export async function getProjectEntriesFunc (owner, projectsId, branch) {
|
||||
const url = `${baseUrl}/${owner}/${projectsId}/entries.json`;
|
||||
if (__SERVER__) {
|
||||
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
|
||||
}
|
||||
return axiosInstance.get(url, {params: { ref: branch }});
|
||||
}
|
||||
|
||||
export async function getBannerFunc (owner, projectsId) {
|
||||
const url = `${baseUrl}/${owner}/${projectsId}/menu_list.json`;
|
||||
if (__SERVER__) {
|
||||
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
|
||||
}
|
||||
return axiosInstance.get(url);
|
||||
}
|
||||
|
||||
export async function getProjectReadMe (owner, projectsId, branch) {
|
||||
const url = `${baseUrl}/${owner}/${projectsId}/readme.json`;
|
||||
if (__SERVER__) {
|
||||
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
|
||||
}
|
||||
return axiosInstance.get(url, {params: { ref: branch }});
|
||||
}
|
||||
|
||||
export async function getOwnerInfo (owner) {
|
||||
const url = `${baseUrl}/owners/${owner}.json`;
|
||||
if (__SERVER__) {
|
||||
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
|
||||
}
|
||||
return axiosInstance.get(url);
|
||||
}
|
||||
|
||||
|
||||
export async function getMainInfos (deptId) {
|
||||
const url = `${baseZoneUrl}/zone/open/zoneKey/${deptId}`;
|
||||
if (__SERVER__) {
|
||||
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
|
||||
}
|
||||
return axiosInstance.get(url);
|
||||
}
|
||||
|
||||
export async function getNewsDetail (id) {
|
||||
const url = `${baseZoneUrl}/cms/doc/open/${id}`;
|
||||
if (__SERVER__) {
|
||||
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
|
||||
}
|
||||
return axiosInstance.get(url);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue