diff --git a/public/index.html b/public/index.html index cd69496c..f00c2ce4 100644 --- a/public/index.html +++ b/public/index.html @@ -33,25 +33,29 @@ <% if (process.env.VUE_APP_NODE_ENV === 'dev') { %> <% } %> <% if (process.env.VUE_APP_NODE_ENV === 'prod:sit') { %> <% } %> <% if (process.env.VUE_APP_NODE_ENV === 'prod:uat') { %> <% } %> <% if (process.env.VUE_APP_NODE_ENV === 'prod') { %> <% } %> diff --git a/src/router/index.js b/src/router/index.js index e5011253..f91549cd 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -2,6 +2,7 @@ import Vue from 'vue' import Router from 'vue-router' import http from '@/utils/request' import { isURL } from '@/utils/validate' +import Cookies from 'js-cookie' Vue.use(Router) @@ -46,6 +47,10 @@ const router = new Router({ }) router.beforeEach((to, from, next) => { + var token = Cookies.get('token') + if (to.path === '/login' && token !== undefined && token !== null && token !== '') { + return next({ name: 'home' }) + } // 添加动态(菜单)路由 // 已添加或者当前路由为页面路由, 可直接访问 if (window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || fnCurrentRouteIsPageRoute(to, pageRoutes)) { diff --git a/src/views/main-sidebar.vue b/src/views/main-sidebar.vue index 93ad0662..551cb5aa 100644 --- a/src/views/main-sidebar.vue +++ b/src/views/main-sidebar.vue @@ -101,7 +101,8 @@ export default { }, connection () { // 建立连接对象 - this.socket = new SockJS('http://219.146.91.110:9094/epdc-api/ws/menuNoticeEndpoint')// 连接服务端提供的通信接口,连接以后才可以订阅广播消息和个人消息,注意这里用的是http而不是原生WebSocket的ws + let socketUrl = window.SITE_CONFIG['socketURL'] + '/ws/menuNoticeEndpoint' + this.socket = new SockJS(socketUrl)// 连接服务端提供的通信接口,连接以后才可以订阅广播消息和个人消息,注意这里用的是http而不是原生WebSocket的ws // 获取STOMP子协议的客户端对象 this.stompClient = Stomp.over(this.socket)