diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 1e1a3f8..117ec95 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -825,8 +825,7 @@ export default { if (abb.length + 1 >= filename.length) { return filename } - // return prev + "…" + next - return filename + return prev + "…" + next } }, getSummaries2() { diff --git a/src/store/modules/user.js b/src/store/modules/user.js index c5bcc95..876ab4c 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -21,6 +21,7 @@ import router from '@/router' import Layout from '@/layout' import ParentView from '@/components/ParentView' import api from "@/api/file-api"; +import {disconnect} from "@/websocket/sockJS"; const getDefaultState = () => { return { @@ -95,7 +96,7 @@ const actions = { login({ commit }, userInfo) { const { username, password, rememberMe } = userInfo return new Promise((resolve, reject) => { - login({ username: username.trim(), password: password }).then(response => { + login({ username: username.trim(), password: password, rememberMe: rememberMe }).then(response => { const { data } = response commit('SET_TOKEN', data.jmalToken) setToken(data.jmalToken) @@ -169,8 +170,10 @@ const actions = { logout({ commit, state }) { return new Promise((resolve, reject) => { logout(state.token).then(() => { - removeToken() // must remove token first + disconnect() + removeToken() removeConsumerId() + removeRememberName() resetRouter() commit('RESET_STATE') resolve() diff --git a/src/utils/auth.js b/src/utils/auth.js index 70ddf93..a91fa9e 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,6 +1,6 @@ import Cookies from 'js-cookie' -const tokenKey = 'jmal_token' +const tokenKey = 'jmal-token' const usernameKey = 'username' const shareTokenKey = 'share-token' const consumerId = 'consumerId' diff --git a/src/websocket/sockJS.js b/src/websocket/sockJS.js index f48ed77..e97a0fb 100644 --- a/src/websocket/sockJS.js +++ b/src/websocket/sockJS.js @@ -9,7 +9,6 @@ export function toConnection(username,token) { ws.timer = setInterval(() => { try { if(ws.isConnected){ - console.log('isConnected', ws.isConnected) ws.stompClient.send("test"); }else{ connect(username, token); @@ -17,12 +16,12 @@ export function toConnection(username,token) { } catch (err) { connect(username, token); } - }, 10000); + }, 5000); } function connect(username,token){ //地址+端点路径,构建websocket链接地址,注意,对应config配置里的addEndpoint - let socket = new SockJS(ws.url + '/mq' + '?name='+username+'&jmal-token='+token); + let socket = new SockJS(ws.url + '/mq'); // 获取STOMP子协议的客户端对象 ws.stompClient = Stomp.over(socket); // 定义客户端的认证信息,按需求配置 @@ -49,7 +48,7 @@ function connect(username,token){ } export function disconnect() { - if (ws.stompClient) { + if (ws.isConnected) { ws.stompClient.disconnect(); } clearInterval(ws.timer);