Commit a30aec8f authored by 赵啸非's avatar 赵啸非

添加检测是否首次安装

parent 36ec01f3
import axios from "axios";
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import Qs from "qs";
const JSONbig = require("json-bigint")({ storeAsString: true });
import cookie from "./cookie";
import httpErrorHandler from "./httpErrorHandler";
// loading框设置局部刷新,且所有请求完成后关闭loading框
let loading
let needLoadingRequestCount = 0 // 声明一个对象用于存储请求个数
function startLoading () {
loading = Vue.prototype.$loading({
lock: true,
customClass: 'createLoading', // 局部class名称
text: '服务加载中...',
background: 'rgba(0,0,0,0.5)',
target: document.querySelector('.loading-area') // 设置加载动画区域
})
}
function endLoading () {
loading.close()
}
function showFullScreenLoading () {
if (needLoadingRequestCount === 0) {
startLoading()
}
needLoadingRequestCount++
}
function hideFullScreenLoading () {
if (needLoadingRequestCount <= 0) return
needLoadingRequestCount--
if (needLoadingRequestCount === 0) {
endLoading()
}
}
const instance = axios.create({
baseURL: "/m",
//baseURL: process.env.VUE_APP_BASE_API,
......@@ -24,18 +56,30 @@ const instance = axios.create({
},
],
});
/**
* 请求拦截器
*/
instance.interceptors.request.use(
(config) => {
config.headers.Authorization = window.sessionStorage.getItem("token") || "";
if (config.isLoading == true) { // 如果配置了isLoading: false,则不显示loading
showFullScreenLoading()
}
return config;
},
(err) => {
hideFullScreenLoading()
return Promise.reject(err);
}
);
/**
* 响应拦截器
*/
instance.interceptors.response.use((response) => {
hideFullScreenLoading() // 响应成功关闭loading
return response.data;
}, httpErrorHandler);
......@@ -98,3 +142,5 @@ export function upload(url, option, config = {}) {
});
return uploadInstance.post(url, formdata, config);
}
export default (error) => {
if(error.message === '自动取消ajax操作') return Promise.reject(error);
if (!error.response) {
console.error(error);
......@@ -50,4 +51,3 @@ export default (error) => {
status,
});
}
\ No newline at end of file
This diff is collapsed.
......@@ -39,8 +39,8 @@ module.exports = {
proxy: {
"/m": {
// target: "http://192.168.0.98:11019",
target: 'http://127.0.0.1:18000',
// target: 'http://192.168.0.98:8081',
// target: 'http://127.0.0.1:18000',
target: 'http://192.168.0.250:18000',
changeOrigin: true,
secure: false
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment