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'; import React, { useEffect, useState } from 'react';
const UploadContext = React.createContext(); const UploadContext = React.createContext();
...@@ -25,27 +25,11 @@ const PictureWallProvider = props => { ...@@ -25,27 +25,11 @@ const PictureWallProvider = props => {
.catch(err => { .catch(err => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(err); console.error(err);
return sleep(3000).then(update); return sleep(15000).then(update);
}); });
useEffect(() => { useEffect(() => {
update(); 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 ( return (
<UploadContext.Provider value={{ imgBed, update }}> <UploadContext.Provider value={{ imgBed, update }}>
{children} {children}
......
...@@ -18,6 +18,7 @@ const mapDispatch = dispatch => ({ ...@@ -18,6 +18,7 @@ const mapDispatch = dispatch => ({
setAuth: auth => dispatch(actionCreators.setAuth(auth)), setAuth: auth => dispatch(actionCreators.setAuth(auth)),
logout: () => { logout: () => {
localStorage.setItem('token', ''); localStorage.setItem('token', '');
localStorage.setItem('panda-publish', '');
dispatch(actionCreators.setAuth([])); dispatch(actionCreators.setAuth([]));
}, },
setUserMode: userMode => dispatch(actionCreators.setUserMode(userMode)), setUserMode: userMode => dispatch(actionCreators.setUserMode(userMode)),
......
...@@ -88,13 +88,11 @@ const Login = props => { ...@@ -88,13 +88,11 @@ const Login = props => {
gateWayConfig() gateWayConfig()
.then(res => { .then(res => {
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
window.DicNameSERVICE = 'GateWay'; localStorage.setItem('panda-publish', 'getway');
} else {
window.DicNameSERVICE = '';
} }
}) })
.catch(err => { .catch(err => {
window.DicNameSERVICE = ''; console.error(err);
}); });
}; };
useEffect(() => { useEffect(() => {
......
import { request } from '../utils/request'; import { request } from '../utils/request';
let isGateWay = false; const CITY_SERVICE = '/Cityinterface/rest/services';
console.log(window, 'window', isGateWay);
const CITY_SERVICE = isGateWay
? '/Publish/GateWay/CityServer'
: '/Cityinterface/rest/services';
// export const CITY_SERVICE = '/Publish/GateWay/CityServer'; // 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'; // export const PUBLISH_SERVICE = '/Publish/GateWay/OMS';
console.log(CITY_SERVICE, PUBLISH_SERVICE);
const get = async (url, params, options = {}) => const get = async (url, params, options = {}) =>
request({ request({
url, url,
......
...@@ -29,9 +29,16 @@ const getMatchedConfig = requestConfig => { ...@@ -29,9 +29,16 @@ const getMatchedConfig = requestConfig => {
axios.defaults.withCredentials = true axios.defaults.withCredentials = true
axios.interceptors.request.use( function (request){ axios.interceptors.request.use( function (request){
const token = localStorage.getItem('token') const token = localStorage.getItem('token')
const pandaPublish = localStorage.getItem('panda-publish')
const getWay = '/Publish/GateWay'
if(token){ if(token){
request.headers.Authorization = 'Bearer ' + token request.headers.Authorization = 'Bearer ' + token
} }
if(pandaPublish){
if(request.url!='/Publish/OMS/OMSLogin')
request.url=getWay+request.url
}
console.log(getWay)
return request return request
}, function (error) { }, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger // 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