Commit 7dd2e318 by liguokang

feat: 🎨

parent e71de27c
import axios from 'axios'; import axios from 'axios';
import { load as cookieLoad, save as cookieSave } from 'react-cookies'; import { load as cookieLoad, save as cookieSave } from 'react-cookies';
const { webDomain, apiDomain } = require('./common/webConfigs');
// 创建axios实例 // 创建axios实例
let serverPath = window.CONFIG.server; let serverPath = apiDomain;
if (SERVER) {
serverPath = SERVER;
}
const service = axios.create({ const service = axios.create({
baseURL: serverPath, // api 的 base_url baseURL: serverPath, // api 的 base_url
...@@ -41,15 +38,7 @@ service.interceptors.response.use( ...@@ -41,15 +38,7 @@ service.interceptors.response.use(
// 坚决禁止在response中做业务异常操作 // 坚决禁止在response中做业务异常操作
const rejectCode = []; const rejectCode = [];
if (code < 200 || code > 300) { if (code < 200 || code > 300) {
if (code == 418) {
window.location.href = 'https://www.xiaomai5.com/maintain.html';
} else if (code == 401 || code == 403) {
User.loginIn();
} else {
processHttpError(response); processHttpError(response);
}
return data;
// return Promise.reject(new Error('error'));
} else { } else {
if (rejectCode.indexOf(code) > -1) { if (rejectCode.indexOf(code) > -1) {
console.table({ console.table({
...@@ -58,22 +47,14 @@ service.interceptors.response.use( ...@@ -58,22 +47,14 @@ service.interceptors.response.use(
errorInfo: message || result, errorInfo: message || result,
path: response.config.url, path: response.config.url,
}); });
// return Promise.reject(data); return Promise.reject(data);
} }
return data; return data;
} }
}, },
(error) => { (error) => {
let code = 0;
try { try {
code = error.response.data.status;
if (code == 418) {
window.location.href = 'https://www.xiaomai5.com/maintain.html';
} else if (code == 401 || code == 403) {
User.loginIn();
} else {
processHttpError(error.response); processHttpError(error.response);
}
} catch (e) { } catch (e) {
if (error.toString().indexOf('Error: timeout') !== -1) { if (error.toString().indexOf('Error: timeout') !== -1) {
console.table({ console.table({
......
...@@ -2,15 +2,13 @@ ...@@ -2,15 +2,13 @@
* @Author: liguokang * @Author: liguokang
* @Date: 2021-07-29 16:19:43 * @Date: 2021-07-29 16:19:43
* @LastEditors: liguokang * @LastEditors: liguokang
* @LastEditTime: 2021-07-29 16:37:35 * @LastEditTime: 2021-07-29 16:46:20
* @Description: * @Description:
* @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有 * @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有
*/ */
const DEPLOY_ENV = process.env.DEPLOY_ENV; const DEPLOY_ENV = process.env.DEPLOY_ENV;
console.log(DEPLOY_ENV, '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@');
const webDomain = { const webDomain = {
dev: 'https://dev.xiaomai5.com/', dev: 'https://dev.xiaomai5.com/',
rc: 'https://rc.xiaomai5.com/', rc: 'https://rc.xiaomai5.com/',
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: liguokang * @Author: liguokang
* @Date: 2021-07-14 20:36:28 * @Date: 2021-07-14 20:36:28
* @LastEditors: liguokang * @LastEditors: liguokang
* @LastEditTime: 2021-07-29 16:34:27 * @LastEditTime: 2021-07-29 16:45:28
* @Description: * @Description:
* @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有 * @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -27,6 +27,7 @@ module.exports = withLessExcludeAntd({ ...@@ -27,6 +27,7 @@ module.exports = withLessExcludeAntd({
return Object.assign({ return Object.assign({
'/': { page: '/' }, '/': { page: '/' },
'/404.html': { page: '/404' }, '/404.html': { page: '/404' },
'/wheatSchool.html': { page: '/wheatSchool' },
}); });
}, },
webpack(config, options) { webpack(config, options) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: liguokang * @Author: liguokang
* @Date: 2021-07-29 16:14:30 * @Date: 2021-07-29 16:14:30
* @LastEditors: liguokang * @LastEditors: liguokang
* @LastEditTime: 2021-07-29 16:41:22 * @LastEditTime: 2021-07-29 16:46:12
* @Description: * @Description:
* @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有 * @Copyrigh: ©2021 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -13,8 +13,6 @@ const { webDomain, apiDomain } = require('./common/webConfigs'); ...@@ -13,8 +13,6 @@ const { webDomain, apiDomain } = require('./common/webConfigs');
const readStream = fs.createReadStream('./sitemap/sitemap.html', { encoding: 'utf8' }); const readStream = fs.createReadStream('./sitemap/sitemap.html', { encoding: 'utf8' });
const writeStream = fs.createWriteStream('./dist/sitemap.html', { encoding: 'utf8' }); const writeStream = fs.createWriteStream('./dist/sitemap.html', { encoding: 'utf8' });
console.log(webConfigs, '11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111');
readStream.on('data', (data) => { readStream.on('data', (data) => {
let reData = data.replace(/https\:\/\/www\.xiaomai5\.com\//g, webDomain); let reData = data.replace(/https\:\/\/www\.xiaomai5\.com\//g, webDomain);
reData = reData.replace(/https\:\/\/heimdall\.xiaomai5\.com\//g, apiDomain); reData = reData.replace(/https\:\/\/heimdall\.xiaomai5\.com\//g, apiDomain);
......
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