import { store } from '@/store' ; import { IUserType } from '@/types/store' ; interface IValue { permission : IPermission ; } type IPermission = string | string [ ] ; function isAllowed ( permission , user , permissions ) { if ( user . admin ) { return true ; } if ( typeof permission === 'string' ) { return permissions . includes ( permission ) ; } if ( permission instanceof Array ) { return permission . some ( auth => permissions . indexOf ( auth ) >= 0 ) ; } return false ; } param value export function checkPermission ( value ) { let permission = value . permission ; const { user , permissions } = store . getState ( ) . app ; const isAllow = isAllowed ( permission , user , permissions ) ; if ( ! isAllow && permission ) { return false ; } return true ; }