zycp-demo/src/main.js

31 lines
702 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'
axios.interceptors.request.use(config => {
2022-03-03 07:51:49 +00:00
if (config.url!="/api/api/user/login-by-Phone"&&config.url!="/api/api/common/send-sms-captcha") {
if (!localStorage.userData) {
2022-03-04 12:25:37 +00:00
router.replace('/login');
return config
2022-03-03 07:51:49 +00:00
}else{
config.headers.Authorization = "Bearer "+JSON.parse(localStorage.userData).token
}
}
2022-03-03 05:41:12 +00:00
return config
})
2022-03-03 03:40:29 +00:00
Vue.use(VueAxios, axios)
2022-03-03 03:28:10 +00:00
new Vue({
router,
render: h => h(App)
}).$mount('#app')