Explorar el Código

全局数据存储用户编号

RuoYi hace 2 años
padre
commit
af03fefc83
Se han modificado 1 ficheros con 5 adiciones y 0 borrados
  1. 5 0
      ruoyi-ui/src/store/modules/user.js

+ 5 - 0
ruoyi-ui/src/store/modules/user.js

@@ -4,6 +4,7 @@ import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
4 4
 const user = {
5 5
   state: {
6 6
     token: getToken(),
7
+    id: '',
7 8
     name: '',
8 9
     avatar: '',
9 10
     roles: [],
@@ -17,6 +18,9 @@ const user = {
17 18
     SET_EXPIRES_IN: (state, time) => {
18 19
       state.expires_in = time
19 20
     },
21
+    SET_ID: (state, id) => {
22
+      state.id = id
23
+    },
20 24
     SET_NAME: (state, name) => {
21 25
       state.name = name
22 26
     },
@@ -64,6 +68,7 @@ const user = {
64 68
           } else {
65 69
             commit('SET_ROLES', ['ROLE_DEFAULT'])
66 70
           }
71
+          commit('SET_ID', user.userId)
67 72
           commit('SET_NAME', user.userName)
68 73
           commit('SET_AVATAR', avatar)
69 74
           resolve(res)