refactor: 优化代码
This commit is contained in:
parent
b0f720bb1e
commit
ac3093641f
|
@ -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
|
||||
|
||||
|
@ -18,8 +18,6 @@ export const roles = {
|
|||
|
||||
function checkRolePermission(el, binding, type) {
|
||||
const {value} = binding;
|
||||
const rolesString = localStorage.getItem("roles");
|
||||
const roles = rolesString.split(',');
|
||||
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']"`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue