Merge pull request '修改API调用指向路径及发布任务时的判断逻辑' (#254) from tongChong/forgeplus-react:hotfix_api_address into pre_dev_military

This commit is contained in:
baladiwei 2021-11-10 15:04:28 +08:00
commit d9bd0387db
5 changed files with 15 additions and 33 deletions

View File

@ -116,7 +116,7 @@
}, },
"scripts": { "scripts": {
"start": "node --max_old_space_size=15360 scripts/start.js", "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", "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", "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", "gen_stats": "NODE_ENV=production webpack --profile --config=./config/webpack.config.prod.js --json > stats.json",

View File

@ -57,6 +57,7 @@ export function initAxiosInterceptors(props) {
var var
proxy = "http://localhost:3000"; proxy = "http://localhost:3000";
proxy = "https://forge.osredm.com"; proxy = "https://forge.osredm.com";
// proxy = "http://117.50.100.12:49999";
const requestMap = {}; const requestMap = {};
window.setfalseInRequestMap = function (keyName) { window.setfalseInRequestMap = function (keyName) {

View File

@ -3,18 +3,9 @@ import axios from 'axios';
import cookie from 'react-cookies'; import cookie from 'react-cookies';
let actionUrl = ''; let settings=JSON.parse(localStorage.chromesetting);
if (window.location.href.indexOf('localhost') > -1) { let actionUrl = settings.api_urls? settings.api_urls.task :'https://task.osredm.com';
actionUrl='https://taskapi.osredm.com'; if (window.location.href.indexOf('localhost') < 0) {
// 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";
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;
} }
export const httpUrl = actionUrl; export const httpUrl = actionUrl;

View File

@ -1,26 +1,18 @@
import { notification,message } from 'antd'; import { notification } from 'antd';
import axios from 'axios'; import axios from 'axios';
import cookie from 'react-cookies'; import cookie from 'react-cookies';
let actionUrl = ''; let settings = JSON.parse(localStorage.chromesetting);
if (window.location.href.indexOf('localhost') > -1) { let actionUrl = settings.api_urls ? settings.api_urls.notice : 'https://info.osredm.com';
actionUrl='https://taskapi.osredm.com'; if (window.location.href.indexOf('localhost')< 0) {
// 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";
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;
} }
export const httpUrl = actionUrl; export const httpUrl = actionUrl;
const TokenKey = 'autologin_forge_military'; const TokenKey = 'autologin_forge_military';
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({
baseURL: httpUrl, baseURL: httpUrl,
@ -91,7 +83,7 @@ service.interceptors.response.use(
}, },
error => { error => {
console.log(error); console.log(error);
let res = error.response||{}; let res = error.response || {};
if (res.status === 400) { if (res.status === 400) {
notification.open({ notification.open({
message: "提示", message: "提示",
@ -111,7 +103,7 @@ service.interceptors.response.use(
message: "提示", message: "提示",
description: res.data.message || '无权限!', description: res.data.message || '无权限!',
}); });
window.location.href="/403"; window.location.href = "/403";
return Promise.reject('error'); return Promise.reject('error');
} }

View File

@ -198,7 +198,7 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification,
showNotification("任务保存成功!"); showNotification("任务保存成功!");
if (!status) { if (!status) {
history.push("/task/myTask?published=false") history.push("/task/myTask?published=false")
} else if (publishMode == '1') { } else {
info({ info({
title: '提示', title: '提示',
content: <div> content: <div>
@ -209,8 +209,6 @@ export default Form.create()(forwardRef(({ current_user, form, showNotification,
history.push("/task/myTask?published=false"); history.push("/task/myTask?published=false");
}, },
}); });
} else {
history.push("/task/myTask");
} }
} else { } else {
showNotification(res.message); showNotification(res.message);