12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import axios from 'axios'
- import { Sequelize, EventBus } from 'base-core-lib'
- const ignoreUrl = ['notice-se/notice/query/noticeNumber', 'purchase-se/supplySparepartStoreInfo/query/getPageHisBy', '/pbHelpQuestionBank/query/getNoviceGuideData']
- const instance = axios.create({
- baseURL: process.env.VUE_APP_BASE_API,
- withCredentials: process.env.VUE_APP_WITHCREDENTIALS,
- timeout: process.env.VUE_APP_AJAX_TIMEOUT
- })
- console.log(process.env,1234455)
- instance.interceptors.request.use(
- (config) => {
- if(config.params){
- if(config.params.loadingstatus){
- // EventBus.$emit('hideLoading')
- }else{
- if (ignoreUrl.indexOf(config.url) === -1) {
- EventBus.$emit('showLoading')
- }
- }
- }else{
- if (ignoreUrl.indexOf(config.url) === -1) {
- EventBus.$emit('showLoading')
- }
- }
-
- // console.info(config.url, 'config.url')
- console.log(config, 'config.url')
-
- return config
- },
- (error) => {
- console.log(error) // for debug
- return Promise.reject(error)
- },
- )
- // 添加一个响应拦截器
- instance.interceptors.response.use(
- (response) => {
- // Do something with response data
- // console.log('response->', response)
- closeLoading()
- return response
- },
- (error) => {
- console.log(error, 'error')
- // Do something with response error
- closeLoading()
- return Promise.reject(error)
- },
- )
- function closeLoading () {
- setTimeout(() => {
- EventBus.$emit('hideLoading')
- }, 200)
- }
- export const appRx = new Sequelize({}, instance)
|