From ba09ccd7346a2e0aa8a1ac55b5cc46eb9cb057af Mon Sep 17 00:00:00 2001
From: zhouwx <1175765986@qq.com>
Date: Fri, 02 Aug 2024 08:39:53 +0800
Subject: [PATCH] 责任人
---
src/util/request.js | 33 ++++++++++++++++++++++-----------
1 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/util/request.js b/src/util/request.js
index 965afa7..a935bed 100644
--- a/src/util/request.js
+++ b/src/util/request.js
@@ -3,6 +3,7 @@
import { Session } from '@/util/storage';
import {message} from "ant-design-vue";
import { loginOut } from "@/api/login";
+import JSONBig from 'json-bigint';
//用来拦截用的
axios.defaults.headers.post["Content-Type"] = "application/json;charset=utf-8";
//创建一个单例
@@ -10,7 +11,17 @@
const { baseUrl } = require('../../config/env.' + process.env.NODE_ENV)
const http= axios.create({
baseURL: baseUrl,
- timeout: 5000,//响应时间
+ timeout: 50000,//响应时间
+ transformResponse: [
+ function (data) {
+ // 对 data 进行任意转换处理
+ try {
+ return JSONBig.parse(data)
+ } catch (err) {
+ return data
+ }
+ }
+ ]
// headers:{"Content-Type":"application/json;charset=utf-8"},
})
@@ -59,17 +70,17 @@
(error) => {
// 对响应错误做点什么
if (error.message.indexOf('timeout') != -1) {
- message.error('网络超时');
- setTimeout(() => {
- Session.clear()
- window.location.href = '/';
- }, 1000);
+ message.error('网络超时')
+ // setTimeout(() => {
+ // Session.clear()
+ // window.location.href = '/'
+ // }, 1000)
} else if (error.message == 'Network Error') {
- message.error('网络连接错误');
- setTimeout(() => {
- Session.clear();
- window.location.href = '/';
- }, 1000);
+ message.error('网络连接错误')
+ // setTimeout(() => {
+ // Session.clear()
+ // window.location.href = '/'
+ // }, 1000)
} else {
if (error.response.data) message.error(error.response.data.error);
else message.error('接口路径找不到');
--
Gitblit v1.9.2