zycp-demo/src/main.js

41 lines
975 B
JavaScript
Raw Normal View History

2022-03-03 03:28:10 +00:00
import Vue from 'vue'
2022-03-03 03:40:29 +00:00
import axios from 'axios'
import VueAxios from 'vue-axios'
2022-03-03 03:28:10 +00:00
import App from './App.vue'
import router from './router'
2022-03-04 12:25:37 +00:00
2022-03-03 05:41:12 +00:00
// Vue.config.productionTip = false
2022-03-03 07:51:49 +00:00
Vue.prototype.host = 'https://ypzy.emingren.com'
2022-03-03 05:41:12 +00:00
Vue.prototype.HOME = '/api'
2022-03-07 11:31:43 +00:00
// 添加请求拦截器具
2022-03-03 05:41:12 +00:00
axios.interceptors.request.use(config => {
2022-03-07 11:31:43 +00:00
if (config.url != "/api/api/user/login-by-Phone" && config.url != "/api/api/common/send-sms-captcha") {
if (!localStorage.userData) {
router.replace('/login');
return config
} else {
config.headers.Authorization = "Bearer " + JSON.parse(localStorage.userData).token
}
}
return config
})
2022-03-03 07:51:49 +00:00
2022-03-07 11:31:43 +00:00
// 添加响应拦截器
// axios.interceptors.response.use(response => {
// // console.log(response);
// let res = {}
// res.status = response.status
// res.data = response.data
// return res;
// }, function(err) {
// return Promise.reject(err)
// });
2022-03-03 05:41:12 +00:00
2022-03-03 03:40:29 +00:00
Vue.use(VueAxios, axios)
2022-03-03 03:28:10 +00:00
new Vue({
2022-03-07 11:31:43 +00:00
router,
render: h => h(App)
2022-03-03 03:28:10 +00:00
}).$mount('#app')