Commit 57c4eeab authored by Maofei94's avatar Maofei94

perf: 修改请求地址

parent adb59167
Pipeline #22194 skipped with stages
import { getImageBases, gateWayConfig } from '@/services/common/api';
import { getImageBases } from '@/services/common/api';
import React, { useEffect, useState } from 'react';
const UploadContext = React.createContext();
......@@ -25,27 +25,11 @@ const PictureWallProvider = props => {
.catch(err => {
// eslint-disable-next-line no-console
console.error(err);
return sleep(3000).then(update);
return sleep(15000).then(update);
});
useEffect(() => {
update();
}, []);
// const updateDicName = () => {
// gateWayConfig()
// .then(res => {
// if (res.code === 0 && res.data) {
// window.DicNameSERVICE = 'GateWay';
// } else {
// window.DicNameSERVICE = '';
// }
// })
// .catch(err => {
// window.DicNameSERVICE = '';
// });
// };
// useEffect(() => {
// updateDicName();
// }, []);
return (
<UploadContext.Provider value={{ imgBed, update }}>
{children}
......
......@@ -18,6 +18,7 @@ const mapDispatch = dispatch => ({
setAuth: auth => dispatch(actionCreators.setAuth(auth)),
logout: () => {
localStorage.setItem('token', '');
localStorage.setItem('panda-publish', '');
dispatch(actionCreators.setAuth([]));
},
setUserMode: userMode => dispatch(actionCreators.setUserMode(userMode)),
......
......@@ -88,13 +88,11 @@ const Login = props => {
gateWayConfig()
.then(res => {
if (res.code === 0 && res.data) {
window.DicNameSERVICE = 'GateWay';
} else {
window.DicNameSERVICE = '';
localStorage.setItem('panda-publish', 'getway');
}
})
.catch(err => {
window.DicNameSERVICE = '';
console.error(err);
});
};
useEffect(() => {
......
import { request } from '../utils/request';
let isGateWay = false;
console.log(window, 'window', isGateWay);
const CITY_SERVICE = isGateWay
? '/Publish/GateWay/CityServer'
: '/Cityinterface/rest/services';
const CITY_SERVICE = '/Cityinterface/rest/services';
// export const CITY_SERVICE = '/Publish/GateWay/CityServer';
const PUBLISH_SERVICE = isGateWay ? '/Publish/GateWay/OMS' : '/Publish/OMS';
const PUBLISH_SERVICE = '/Publish/OMS';
// export const PUBLISH_SERVICE = '/Publish/GateWay/OMS';
console.log(CITY_SERVICE, PUBLISH_SERVICE);
const get = async (url, params, options = {}) =>
request({
url,
......
......@@ -29,9 +29,16 @@ const getMatchedConfig = requestConfig => {
axios.defaults.withCredentials = true
axios.interceptors.request.use( function (request){
const token = localStorage.getItem('token')
const pandaPublish = localStorage.getItem('panda-publish')
const getWay = '/Publish/GateWay'
if(token){
request.headers.Authorization = 'Bearer ' + token
}
if(pandaPublish){
if(request.url!='/Publish/OMS/OMSLogin')
request.url=getWay+request.url
}
console.log(getWay)
return request
}, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment