forked from Gitlink/forgeplus-react
88 lines
2.2 KiB
JavaScript
88 lines
2.2 KiB
JavaScript
import axios from 'axios';
|
|
import { url, zoneUrl } from '../ssrUrl';
|
|
|
|
let baseUrl = `${url}/api`
|
|
let baseZoneUrl = `${zoneUrl}/api`
|
|
|
|
if (__CLIENT__) {
|
|
let settings = localStorage.chromesetting && localStorage.chromesetting !== 'undefined' &&JSON.parse(localStorage.chromesetting);
|
|
baseUrl = settings && settings.common.main_site_url + '/api';
|
|
baseZoneUrl = settings && settings.common.zone + '/api';
|
|
}
|
|
|
|
const axiosInstance = axios.create({
|
|
withCredentials: true
|
|
});
|
|
|
|
axiosInstance.interceptors.response.use(
|
|
response => {
|
|
return response;
|
|
},
|
|
error => {
|
|
console.log(error);
|
|
}
|
|
)
|
|
|
|
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`;
|
|
setHead()
|
|
return axiosInstance.get(url);
|
|
}
|
|
|
|
export async function getProjectDetailFunc (owner, projectsId) {
|
|
const url = `${baseUrl}/${owner}/${projectsId}/detail.json`;
|
|
setHead()
|
|
return axiosInstance.get(url);
|
|
}
|
|
|
|
export async function getProjectEntriesFunc (owner, projectsId, branch) {
|
|
const url = `${baseUrl}/${owner}/${projectsId}/entries.json`;
|
|
setHead()
|
|
return axiosInstance.get(url, {params: { ref: branch }});
|
|
}
|
|
|
|
export async function getBannerFunc (owner, projectsId) {
|
|
const url = `${baseUrl}/${owner}/${projectsId}/menu_list.json`;
|
|
setHead()
|
|
return axiosInstance.get(url);
|
|
}
|
|
|
|
export async function getProjectReadMe (owner, projectsId, branch) {
|
|
const url = `${baseUrl}/${owner}/${projectsId}/readme.json`;
|
|
setHead()
|
|
return axiosInstance.get(url, {params: { ref: branch }});
|
|
}
|
|
|
|
export async function getOwnerInfo (owner) {
|
|
const url = `${baseUrl}/owners/${owner}.json`;
|
|
setHead()
|
|
return axiosInstance.get(url);
|
|
}
|
|
|
|
|
|
export async function getMainInfos (deptId) {
|
|
const url = `${baseZoneUrl}/zone/open/zoneKey/${deptId}`;
|
|
setHead()
|
|
return axiosInstance.get(url);
|
|
}
|
|
|
|
export async function getNewsDetail (id) {
|
|
const url = `${baseZoneUrl}/cms/doc/open/${id}`;
|
|
setHead()
|
|
return axiosInstance.get(url);
|
|
}
|
|
|
|
export async function getSetting () {
|
|
const url = `${baseUrl}/setting.json`;
|
|
return axiosInstance.get(url);
|
|
}
|