refactor: 优化代码

This commit is contained in:
q4speed 2020-08-28 11:26:32 +08:00
parent b0f720bb1e
commit ac3093641f
1 changed files with 4 additions and 8 deletions

View File

@ -1,6 +1,6 @@
import router from './components/common/router/router'
import {TokenKey} from '../common/js/constants';
import {hasRolePermissions, hasRoles} from "../common/js/utils";
import {TokenKey} from '@/common/js/constants';
import {hasRolePermissions, hasRoles} from "@/common/js/utils";
const whiteList = ['/login']; // no redirect whitelist
@ -17,9 +17,7 @@ export const roles = {
};
function checkRolePermission(el, binding, type) {
const { value } = binding;
const rolesString = localStorage.getItem("roles");
const roles = rolesString.split(',');
const {value} = binding;
if (value && value instanceof Array && value.length > 0) {
const permissionRoles = value;
let hasPermission = false;
@ -31,8 +29,6 @@ function checkRolePermission(el, binding, type) {
if (!hasPermission) {
el.parentNode && el.parentNode.removeChild(el)
}
} else {
// throw new Error(`need roles! Like v-permission="['admin','editor']"`)
}
}