feige
2024-08-29 be4c17512fe93511c21939d594c843b9594b1549
ruoyi-ui/src/store/modules/user.js
@@ -6,6 +6,7 @@
    token: getToken(),
    name: '',
    avatar: '',
   clanId: '',
    roles: [],
    permissions: []
  },
@@ -25,14 +26,17 @@
    },
    SET_PERMISSIONS: (state, permissions) => {
      state.permissions = permissions
    }
    },
   SET_CLANID: (state, clanId) => {
     state.clanId = clanId
   },
  },
  actions: {
    // 登录
    Login({ commit }, userInfo) {
      const username = userInfo.username.trim()
      const nickname = userInfo.nickName.trim()
      const password = userInfo.password
      const code = userInfo.code
@@ -40,7 +44,7 @@
      const uuid = userInfo.uuid
      return new Promise((resolve, reject) => {
        login(username, password, code, uuid).then(res => {
        login(nickname, password, code, uuid).then(res => {
          setToken(res.data.token)
@@ -63,9 +67,14 @@
          if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组
            commit('SET_ROLES', res.roles)
            commit('SET_PERMISSIONS', res.permissions)
          } else {
            commit('SET_ROLES', ['ROLE_DEFAULT'])
          }
       // console.log(res)
       // alert(res.user.clanId)
           commit('SET_CLANID', res.user.clanId)
          commit('SET_NAME', user.userName)
          commit('SET_AVATAR', avatar)
          resolve(res)