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