添加socket的userId
This commit is contained in:
@ -21,8 +21,6 @@ router.beforeEach((to, from, next) => {
|
||||
// 拉取用户信息
|
||||
let menus = res.data.menus;
|
||||
let username = res.data.username;
|
||||
let userId = res.data.userId;
|
||||
localStorage.setItem('userId', userId);
|
||||
next({ ...to, replace: true });
|
||||
// store.dispatch('GenerateRoutes', { menus, username }).then(() => {
|
||||
// // 生成可访问的路由表
|
||||
|
@ -5,6 +5,7 @@ const user = {
|
||||
state: {
|
||||
token: getToken(),
|
||||
name: '',
|
||||
userId: '',
|
||||
avatar: '',
|
||||
roles: [],
|
||||
permissions: []
|
||||
@ -17,6 +18,10 @@ const user = {
|
||||
SET_NAME: (state, name) => {
|
||||
state.name = name;
|
||||
},
|
||||
SET_USER_ID: (state, userId) => {
|
||||
state.userId = userId;
|
||||
localStorage.setItem('userId', userId);
|
||||
},
|
||||
SET_AVATAR: (state, avatar) => {
|
||||
state.avatar = avatar;
|
||||
},
|
||||
@ -81,6 +86,7 @@ const user = {
|
||||
commit('SET_ROLES', ['ROLE_DEFAULT']);
|
||||
}
|
||||
commit('SET_NAME', user.username);
|
||||
commit('SET_USER_ID', user.userId);
|
||||
commit('SET_AVATAR', avatar);
|
||||
resolve(res);
|
||||
})
|
||||
|
@ -97,8 +97,7 @@ import { send } from '@/api/service';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
path:
|
||||
'ws://192.168.0.125:1919/webStock/' + localStorage.getItem('userId'),
|
||||
path: 'ws://192.168.0.125:1919/webStock/' + this.$store.state.user.userId,
|
||||
socket: '',
|
||||
userid: '23941',
|
||||
// 待发送信息
|
||||
|
Reference in New Issue
Block a user