ruoyi-plus-soybean/src/directives/permission.ts
2022-03-30 01:30:12 +08:00

17 lines
430 B
TypeScript

import type { App, Directive } from 'vue';
import { useAuthStore } from '@/store';
export default function setupLoginDirective(app: App) {
const auth = useAuthStore();
const loginDirective: Directive<HTMLElement, Auth.RoleType | undefined> = {
mounted(el: HTMLElement, binding) {
if (binding.value !== auth.userInfo.userRole) {
el.remove();
}
},
};
app.directive('login', loginDirective);
}