| | |
| | | import { isURL, validatenull } from '@/utils/validate'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import website from '@/config/website'; |
| | | import NProgress from 'nprogress'; // progress bar |
| | | import 'nprogress/nprogress.css'; // progress bar style |
| | | import { Base64 } from 'js-base64'; |
| | | import { baseUrl } from '@/config/env'; |
| | | import crypto from '@/utils/crypto'; |
| | |
| | | }; |
| | | //跨域请求,允许保存cookie |
| | | axios.defaults.withCredentials = true; |
| | | // NProgress Configuration |
| | | NProgress.configure({ |
| | | showSpinner: false, |
| | | }); |
| | | |
| | | //http request拦截 |
| | | axios.interceptors.request.use( |
| | | config => { |
| | | // start progress bar |
| | | NProgress.start(); |
| | | // 初始化错误提示状态 |
| | | isErrorShown = false; |
| | | //地址为已经配置状态则不添加前缀 |
| | |
| | | //http response拦截 |
| | | axios.interceptors.response.use( |
| | | res => { |
| | | NProgress.done(); |
| | | const status = res.data.error_code || res.data.code || res.status; |
| | | const statusWhiteList = website.statusWhiteList || []; |
| | | const message = res.data.msg || res.data.error_description || res.data.message || '系统错误'; |
| | |
| | | return res; |
| | | }, |
| | | error => { |
| | | NProgress.done(); |
| | | return Promise.reject(new Error(error)); |
| | | } |
| | | ); |