licp
2024-06-07 32a95699e59c5c65e18c08643266c9cbfa380ee4
src/main.js
@@ -11,11 +11,23 @@
import api from './assets/api/controller.js'
import swal from 'sweetalert'
Vue.prototype.LOCATIONVUE = "http://127.0.0.1:80"; //前端本地端口
const javaApi = 'http://localhost:8001';
// 项目切换
Vue.prototype.PROJECT = '检测中心' //项目名称:检测中心、装备电缆
//本地
Vue.prototype.LOCATIONVUE = "http://127.0.0.1:80";
const javaApi = 'http://192.168.11.200:8001';//李
// const javaApi = 'http://192.168.144.249:8001';//张
// const javaApi = 'http://192.168.11.2:8001';//柴
//  const javaApi = 'http://127.0.0.1:8001';//晏
// const javaApi = 'http://114.132.189.42:1234';//测试服
//胜云服务器
// Vue.prototype.LOCATIONVUE = "http://syxt.shxiao2.cn";
// const javaApi = 'http://122.114.52.69:8001';
Vue.prototype.HaveJson = (val) => {
   return JSON.parse(JSON.stringify(val))
}
Vue.prototype.javaApi = javaApi
Vue.use(VueAxios, axios)
Vue.config.productionTip = false
@@ -56,6 +68,13 @@
})
axios.interceptors.response.use(res => {
   if(res.data.code === 201){
      Message({
      type: 'error',
      dangerouslyUseHTMLString: true,
      message: `${res.data.message}`
    })
   }
   return res.data
}, async function(err) {
   if (JSON.stringify(err).indexOf('timeout of') > -1) {
@@ -80,7 +99,9 @@
         if (res.data.code == 201) {
            Message.error('认证失败,需要重新登录')
            localStorage.removeItem('autoenter')
            window.location.href = '/enter'
            next({
              path: '/enter'
            })
            return Promise.reject(err)
         }
         sessionStorage.setItem('token', res.data.token)
@@ -94,6 +115,10 @@
})
router.beforeEach((to, from, next) => {
   if(to.path.indexOf('/test') == 0){
      next()
      return
   }
  if (to.path.indexOf('/enter') != 0) {
    if (sessionStorage.getItem('token') == null || sessionStorage.getItem('token') == '' || sessionStorage.getItem(
        'token') == undefined) {
@@ -108,5 +133,9 @@
new Vue({
   el: '#app',
   router,
   render: h => h(App)
   render: h => h(App),
  beforeCreate() {
     // 需要在全局添加一个属性
    Vue.prototype.$bus = this
  }
});