UX-2(操作级权限控制)

This commit is contained in:
Cheng Zhou
2025-12-17 15:11:02 +08:00
parent dd51f56707
commit 9ca30d12f8
29 changed files with 288 additions and 131 deletions
@@ -0,0 +1,37 @@
<template>
<el-tooltip v-if="!allowed && tooltip" :content="reason" placement="top">
<span class="perm-wrapper perm-disabled">
<slot />
</span>
</el-tooltip>
<span v-else-if="!allowed" class="perm-wrapper perm-disabled">
<slot />
</span>
<span v-else class="perm-wrapper">
<slot />
</span>
</template>
<script setup lang="ts">
import { computed } from "vue";
import { usePermission } from "../utils/permission";
const props = defineProps<{
action: string;
tooltip?: boolean;
}>();
const { can, reason: reasonFn } = usePermission();
const allowed = computed(() => can(props.action));
const reason = computed(() => reasonFn(props.action));
</script>
<style scoped>
.perm-wrapper {
display: inline-block;
}
.perm-disabled {
opacity: 0.55;
pointer-events: none;
}
</style>