mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-11-12 11:43:42 +08:00
feat(projects): 新增静态路由
This commit is contained in:
16
src/directives/permission.ts
Normal file
16
src/directives/permission.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user