issue页面可能空白问题修复、服务端请求添加header表示

This commit is contained in:
黄心宇 2024-05-22 16:15:12 +08:00
parent 02928e5e28
commit 338d326971
4 changed files with 19 additions and 26 deletions

View File

@ -15,8 +15,9 @@ app.use('/build', express.static('build'));
const options = (target) => {
return {
target: target,
changeOrigin: false, // 不允许在请求头中更改主机
changeOrigin: process.env.NODE_ENV === 'dev' ? true : false, // 服务器不允许在请求头中更改主机
timeout: 30000,
secure: process.env.NODE_ENV === 'dev' ? false : true, // 忽略证书验证
onProxyRes: (proxyRes, req, res) => {
// 代理成功后输出日志
Logger.info(`Proxy to ${req.url} responded with status ${proxyRes.statusCode}`);

View File

@ -47,4 +47,5 @@ export const changeHead = async ({ key }, params) => {
default:
return false
}
return true
}

View File

@ -442,7 +442,7 @@ class Detail extends Component {
defaultBranch: data.default_branch
});
// seo优化设置
let keyWords=`${owner},${projectsId}${ data.topics.length > 0 && ','}${ data.topics.length > 0 && data.topics.map(item => item.name).join(',') }`;
let keyWords=`${owner},${projectsId}${ data.topics && data.topics.length > 0 && ','}${ data.topics && data.topics.length > 0 && data.topics.map(item => item.name).join(',') }`;
let title= `${owner}/${projectsId}${data.description?''+data.description:''}`;
setSeoMeta(keyWords,title,data.description || '',`/${owner}/${projectsId}`,owner,projectsId);
}

View File

@ -23,70 +23,61 @@ axiosInstance.interceptors.response.use(
}
)
const setHead = () => {
if (__SERVER__) {
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
axiosInstance.defaults.headers.isServer = true
}
}
//
export async function getProjectFunc (owner, projectsId) {
const url = `${baseUrl}/${owner}/${projectsId}/simple.json`;
if (__SERVER__) {
axiosInstance.defaults.headers.cookie = domObj.window.document.cookie
}
setHead()
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
}
setHead()
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
}
setHead()
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
}
setHead()
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
}
setHead()
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
}
setHead()
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
}
setHead()
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
}
setHead()
return axiosInstance.get(url);
}