From 9cea3c3abe31746c044db1388d24ee86e343a623 Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 9 Jan 2019 16:04:24 +0800 Subject: [PATCH] refine: GetUserInfo error message --- src/permission.js | 2 +- src/store/modules/user.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/permission.js b/src/permission.js index 81f9d113..e556cb00 100644 --- a/src/permission.js +++ b/src/permission.js @@ -33,7 +33,7 @@ router.beforeEach((to, from, next) => { }) }).catch((err) => { store.dispatch('FedLogOut').then(() => { - Message.error(err || 'Verification failed, please login again') + Message.error(err) next({ path: '/' }) }) }) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 0f7e2296..38e81a36 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -63,15 +63,16 @@ const user = { GetUserInfo({ commit, state }) { return new Promise((resolve, reject) => { getUserInfo(state.token).then(response => { - if (!response.data) { // 由于mockjs 不支持自定义状态码只能这样hack - reject('error') + // 由于mockjs 不支持自定义状态码只能这样hack + if (!response.data) { + reject('Verification failed, please login again.') } const data = response.data if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组 commit('SET_ROLES', data.roles) } else { - reject('getInfo: roles must be a non-null array !') + reject('getInfo: roles must be a non-null array!') } commit('SET_NAME', data.name)