generated from VLADIMIR/template_frontend
fix
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { MenuOutlined } from '@vicons/material'
|
||||
import { Icon } from '@vicons/utils'
|
||||
import { useMessage } from 'naive-ui'
|
||||
import { ref } from 'vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { getAuthClient } from '@/api/auth_client'
|
||||
@@ -19,15 +19,17 @@ const permissions = ref<string[]>([])
|
||||
|
||||
async function getPermissions() {
|
||||
permissions.value = []
|
||||
if (!authStore.user) return
|
||||
const token = authStore.getToken()
|
||||
try {
|
||||
const res = await client.GetPermissions({})
|
||||
permissions.value = res.permissions || []
|
||||
if (token === authStore.getToken()) permissions.value = res.permissions || []
|
||||
} catch (err) {
|
||||
message.error('Не удалось загрузить права доступа')
|
||||
console.error('Failed to load permissions:', err)
|
||||
}
|
||||
}
|
||||
getPermissions()
|
||||
watch(() => authStore.user, getPermissions, { immediate: true })
|
||||
|
||||
function hasPermission(permission: string): boolean {
|
||||
return permissions.value.includes(permission)
|
||||
|
||||
Reference in New Issue
Block a user