main.js
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import Vue from 'vue';
import App from '@/App.vue';
import router from '@/router';
import store from '@/store';
import axios from 'axios';
import '@/api-mock';
import ElementUI from 'element-ui';
import EagleWebToolkit from '../packages';
import NProgress from 'nprogress';
import EagleCodeSnippet from "@/components/code-snippet";
import EagleStringHtml from "@/components/string-html";
import '@/styles/index.scss';
import "highlight.js/styles/github.css";
const request = axios.create({
baseURL: 'http://localhost',
timeout: 1000 * 60,
withCredentials: true,
});
// respone 拦截器
request.interceptors.response.use(
response => {
const { data = {}, config } = response;
const { code = 0 } = data;
if (config && config.interceptors === false) { // 请求配置不做返回拦截的情况
return response;
} else {
if (`${code}` === '0' || `${code}` === '200') { // 请求成功
return data;
} else { // 其它错误,开发环境提示
return { code };
}
}
},
error => {
return { code: 404 };
});
Vue.prototype.$axios = request;
// 进度条配置
NProgress.configure({ showSpinner: false });
// 注册代码片段组件
Vue.component("eagle-code-snippet", EagleCodeSnippet);
Vue.component("eagle-string-html", EagleStringHtml);
// 注册饿了么UI
Vue.use(ElementUI);
// 注册Eagle组件库
Vue.use(EagleWebToolkit);
Vue.config.productionTip = false;
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')