From e85ef78c1a04335df6fc549278553230606c3cd0 Mon Sep 17 00:00:00 2001 From: dyz <43943819+dyzsoft@users.noreply.github.com> Date: Sun, 5 Jul 2020 08:19:56 +0800 Subject: [PATCH 1/2] update permission.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit some包含返回true,不包含返回false,if判断中直接返回some函数结果,精简代码逻辑 --- src/utils/permission.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/utils/permission.js b/src/utils/permission.js index 221d3842..8e2bbada 100644 --- a/src/utils/permission.js +++ b/src/utils/permission.js @@ -13,11 +13,7 @@ export default function checkPermission(value) { const hasPermission = roles.some(role => { return permissionRoles.includes(role) }) - - if (!hasPermission) { - return false - } - return true + return hasPermission } else { console.error(`need roles! Like v-permission="['admin','editor']"`) return false From 4303c78b78faac5933d38540fb3bb94fe502be7b Mon Sep 17 00:00:00 2001 From: dyz <43943819+dyzsoft@users.noreply.github.com> Date: Sat, 18 Jul 2020 16:27:35 +0800 Subject: [PATCH 2/2] pref:delete useless code --- src/store/modules/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 78009412..c46c09ea 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -75,7 +75,7 @@ const actions = { // user logout logout({ commit, state, dispatch }) { return new Promise((resolve, reject) => { - logout(state.token).then(() => { + logout().then(() => { commit('SET_TOKEN', '') commit('SET_ROLES', []) removeToken()