| | |
| | | import axios from 'axios'; |
| | | import { ElMessage, ElMessageBox } from 'element-plus'; |
| | | import { Session } from '/@/utils/storage'; |
| | | import JSONbig from 'json-bigint'; |
| | | import Cookies from 'js-cookie'; |
| | | import {useLoginApi} from "/@/api/login"; |
| | | import { Session, } from '/@/utils/storage'; |
| | | |
| | | // var jsonBig = require('json-bigint')({ "storeAsString": true }); |
| | | // 配置新建一个 axios 实例 |
| | |
| | | config.data[key] = null; |
| | | } |
| | | } |
| | | if (Session.get('token')) { |
| | | (<any>config.headers).common['Authorization'] = `${Session.get('token')}`; |
| | | (<any>config.headers).common['uid'] = `${Session.get('uid')}`; |
| | | if (Cookies.get('token')) { |
| | | (<any>config.headers).common['Authorization'] = `${Cookies.get('token')}`; |
| | | (<any>config.headers).common['uid'] = `${Cookies.get('uid')}`; |
| | | } |
| | | return config; |
| | | }, |
| | |
| | | }, 1000); |
| | | } else if (response.data.code && response.data.code === 'A0215') { |
| | | ElMessage.error('token失效'); |
| | | setTimeout(() => { |
| | | Session.clear(); |
| | | window.location.href = '/'; |
| | | }, 1000); |
| | | // logOut; |
| | | useLoginApi().signOut().then(()=>{ |
| | | setTimeout(() => { |
| | | Session.clear(); |
| | | window.location.href = '/'; |
| | | }, 1000); |
| | | }) |
| | | } |
| | | // if(response.data.code && response.data.code !== '200'){ |
| | | return Promise.resolve(response); |
| | |
| | | if (error.message.indexOf('timeout') != -1) { |
| | | ElMessage.error('网络超时'); |
| | | setTimeout(() => { |
| | | Session.clear(); |
| | | // Session.clear(); |
| | | window.location.href = '/'; |
| | | }, 1000); |
| | | } else if (error.message == 'Network Error') { |