123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import axios from 'axios'
- import { MessageBox } from 'element-ui'
- import $store from '@/store'
- let host = ''
- if (window.location.port === '8080') {
- host = '//test.mee.chat/'
- }
- let ax = axios.create({
- baseURL: host,
- headers: { 'Content-Type': 'multipart/form-data' },
- withCredentials: true
- })
- ax.host = host
- ax.interceptors.response.use(
- response => {
- if (response.data.result === 1 || response.data.code === -1001) {
-
- return Promise.resolve(response)
- } else {
- if (response.data.code === -5) {
-
- $store.dispatch('resetGameLogin')
- } else {
-
- MessageBox.confirm(response.data.msg, 'Error', {
- center: true,
- showCancelButton: false,
- showConfirmButton: false,
- callback () {}
- })
- return Promise.reject(new Error(response.data.msg))
- }
- }
- },
- error => {
- return Promise.reject(error)
- }
- )
- export default ax
|