From a59a8c369393bbaa855cd6e49bd61599ed893be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Wed, 10 Nov 2021 09:33:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8C=87=E5=90=91=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/AppConfig.js | 1 + src/military/fetch.js | 15 +++------------ src/military/notice/fetch.js | 24 ++++++++---------------- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 3e9ecfea..04e606c4 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ }, "scripts": { "start": "node --max_old_space_size=15360 scripts/start.js", - "build": "cross-env NODE_ENV=production node --max_old_space_size=15360 scripts/build.js", + "build": " NODE_ENV=production node --max_old_space_size=15360 scripts/build.js", "test-build": "NODE_ENV=testBuild node --max_old_space_size=15360 scripts/build.js", "pre-build": "NODE_ENV=preBuild node --max_old_space_size=15360 scripts/build.js", "gen_stats": "NODE_ENV=production webpack --profile --config=./config/webpack.config.prod.js --json > stats.json", diff --git a/src/AppConfig.js b/src/AppConfig.js index 9bf5e095..1b78e7a9 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -57,6 +57,7 @@ export function initAxiosInterceptors(props) { var proxy = "http://localhost:3000"; proxy = "https://forge.osredm.com"; + // proxy = "http://117.50.100.12:49999"; const requestMap = {}; window.setfalseInRequestMap = function (keyName) { diff --git a/src/military/fetch.js b/src/military/fetch.js index f9ec73f8..956d92a2 100644 --- a/src/military/fetch.js +++ b/src/military/fetch.js @@ -3,18 +3,9 @@ import axios from 'axios'; import cookie from 'react-cookies'; -let actionUrl = ''; -if (window.location.href.indexOf('localhost') > -1) { - actionUrl='https://taskapi.osredm.com'; - // actionUrl='http://192.168.31.47:8081'; -}else if(window.location.href.indexOf('192.168.31.48') > -1){ - actionUrl='https://taskapi.osredm.com'; - axios.defaults.withCredentials = true; -}else if(window.location.href.indexOf('noticeweb.osredm') > -1){ - actionUrl="https://taskapi.osredm.com"; - axios.defaults.withCredentials = true; -}else if(window.location.href.indexOf('forge.osredm.com')>-1){ - actionUrl="https://task.osredm.com"; +let settings=JSON.parse(localStorage.chromesetting); +let actionUrl = settings.api_urls? settings.api_urls.task :'https://task.osredm.com'; +if (window.location.href.indexOf('localhost') < -1) { axios.defaults.withCredentials = true; } export const httpUrl = actionUrl; diff --git a/src/military/notice/fetch.js b/src/military/notice/fetch.js index bede3805..a483562c 100644 --- a/src/military/notice/fetch.js +++ b/src/military/notice/fetch.js @@ -1,26 +1,18 @@ -import { notification,message } from 'antd'; +import { notification, message } from 'antd'; import axios from 'axios'; import cookie from 'react-cookies'; -let actionUrl = ''; -if (window.location.href.indexOf('localhost') > -1) { - actionUrl='https://taskapi.osredm.com'; - // actionUrl='http://192.168.31.47:8081'; -}else if(window.location.href.indexOf('192.168.31.48') > -1){ - actionUrl='https://taskapi.osredm.com'; - axios.defaults.withCredentials = true; -}else if(window.location.href.indexOf('noticeweb.osredm') > -1){ - actionUrl="https://taskapi.osredm.com"; - axios.defaults.withCredentials = true; -}else if(window.location.href.indexOf('forge.osredm.com')>-1){ - actionUrl="https://info.osredm.com"; +let settings=JSON.parse(localStorage.chromesetting); +let actionUrl = settings.api_urls? settings.api_urls.notice :'https://info.osredm.com'; +if (window.location.href.indexOf('localhost') < -1) { axios.defaults.withCredentials = true; } export const httpUrl = actionUrl; const TokenKey = 'autologin_forge_military'; + // 创建axios实例 const service = axios.create({ baseURL: httpUrl, @@ -91,7 +83,7 @@ service.interceptors.response.use( }, error => { console.log(error); - let res = error.response||{}; + let res = error.response || {}; if (res.status === 400) { notification.open({ message: "提示", @@ -111,10 +103,10 @@ service.interceptors.response.use( message: "提示", description: res.data.message || '无权限!', }); - window.location.href="/403"; + window.location.href = "/403"; return Promise.reject('error'); } - + return Promise.reject(error); } );