因為獲取用戶比較簡單,只需要把用戶名及頭像地址賦值即可(也許理解錯誤,如果發現請告知謝謝),
首先將src\api\usr.js中的url請求地址改為以下代碼
export function getInfo(token) { return request({ url: '/api/abp/application-configuration', method: 'get', params: { token } }) }
再將store\modules\user.js中getinfo方法改為以下代碼

// get user info getInfo({ commit, state }) { return new Promise((resolve, reject) => { getInfo(state.token).then(response => { const { data } = response if (!data) { reject('Verification failed, please Login again.') } const { roles, name, avatar, introduction } = data // roles must be a non-empty array if (!roles || roles.length <= 0) { reject('getInfo: roles must be a non-null array!') } commit('SET_ROLES', roles) commit('SET_NAME', name) commit('SET_AVATAR', avatar) commit('SET_INTRODUCTION', introduction) resolve(data) }).catch(error => { reject(error) }) }) },
getInfo({ commit, state }) { return new Promise((resolve, reject) => { getInfo(state.token).then(response => { const { data } = response if (!data) { return reject('Verification failed, please Login again.') } this.name = data.currentUser.userName this.avatar = null commit('SET_NAME', this.name) commit('SET_AVATAR', this.avatar) resolve(data) }).catch(error => { reject(error) }) }) },
登錄測試能正常顯示用戶名,為了能知道當前登錄用戶,我將用戶名顯示到了導航欄
根據https://www.cnblogs.com/flypig666/p/11854538.html增加了一份帶tagsview版本的下載地址