From e4be7a095f31b76d4f3d60c06eefe774ffd264fc Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Wed, 16 Mar 2022 16:20:18 +0800
Subject: [PATCH] +地图添加面 电子围栏
---
src/router/axios.js | 38 ++++++++++++++++++++++++--------------
1 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/router/axios.js b/src/router/axios.js
index caaf171..16948d0 100644
--- a/src/router/axios.js
+++ b/src/router/axios.js
@@ -8,34 +8,42 @@
import axios from 'axios';
import store from '@/store/';
import router from '@/router/router';
-import { serialize } from '@/util/util';
-import { getToken } from '@/util/auth';
+import {
+ serialize
+} from '@/util/util';
+import {
+ getToken
+} from '@/util/auth';
// import { Message } from 'element-ui';
-import { MessageBox } from 'element-ui';
+import {
+ MessageBox
+} from 'element-ui';
import website from '@/config/website';
-import { Base64 } from 'js-base64';
+import {
+ Base64
+} from 'js-base64';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
//默认超时时间
axios.defaults.timeout = 60000;
//返回其他状态码
-axios.defaults.validateStatus = function(status) {
- return status >= 200 && status <= 500;
+axios.defaults.validateStatus = function (status) {
+ return status >= 200 && status <= 500;
};
//跨域请求,允许保存cookie
axios.defaults.withCredentials = true;
// NProgress 配置
NProgress.configure({
- showSpinner: false
+ showSpinner: false
});
//http request拦截
axios.interceptors.request.use(config => {
- //开启 progress bar
- NProgress.start();
- const meta = (config.meta || {});
- const isToken = meta.isToken === false;
- config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`;
+ //开启 progress bar
+ NProgress.start();
+ const meta = (config.meta || {});
+ const isToken = meta.isToken === false;
+ config.headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`;
//让每个请求携带token
if (getToken() && !isToken) {
config.headers[website.tokenHeader] = 'bearer ' + getToken()
@@ -63,7 +71,9 @@
//如果在白名单里则自行catch逻辑处理
if (statusWhiteList.includes(status)) return Promise.reject(res);
//如果是401则跳转到登录页面
- if (status === 401) store.dispatch('FedLogOut').then(() => router.push({path: '/login'}));
+ if (status === 401) store.dispatch('FedLogOut').then(() => router.push({
+ path: '/login'
+ }));
// 如果请求为非200否者默认统一处理
if (status !== 200 & status !== 201) {
// Message({
@@ -80,4 +90,4 @@
return Promise.reject(new Error(error));
});
-export default axios;
\ No newline at end of file
+export default axios;
--
Gitblit v1.9.3