/**
 * 获取按钮权限数据
 */
import { computed } from 'vue'
import { useStore } from 'vuex'
import { lookPermissionUser } from '@/config'

export function usePermission() {
    const store = useStore()
    const userId = computed(() => store.state.user.info.userId || [])

    const permissionCodes = computed(() =>
        // 写死判断用户ID是 888 的用户隐藏掉所有操作
        lookPermissionUser.includes(userId.value) ? [] : ['permission'] 
    )

    const checkPermission = (code) => permissionCodes.value.includes(code)

    return {
        permissionCodes,
        checkPermission,
    }
}
