wujingjing
2024-11-05 9f880255e8961cd26c52a87ad40bada377bab98c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<template>
    <slot v-if="getUserAuthBtnList" />
</template>
 
<script setup lang="ts" name="auths">
import { computed } from 'vue';
import { storeToRefs } from 'pinia';
import { useUserInfo } from '/@/stores/userInfo';
 
// 定义父组件传过来的值
const props = defineProps({
    value: {
        type: Array,
        default: () => [],
    },
});
 
// 定义变量内容
const stores = useUserInfo();
const { userInfos } = storeToRefs(stores);
 
// 获取 pinia 中的用户权限
const getUserAuthBtnList = computed(() => {
    let flag = false;
    userInfos.value.authBtnList.map((val: string) => {
        props.value.map((v) => {
            if (val === v) flag = true;
        });
    });
    return flag;
});
</script>