From f2b771d3ffa7517e29d59a74503d2014760a3a0b Mon Sep 17 00:00:00 2001 From: liuchuang Date: Tue, 5 Nov 2019 10:03:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 8 ++++++-- src/router/index.js | 5 +++++ src/views/main-sidebar.vue | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) 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)