generated from VLADIMIR/template_frontend
add menu
This commit is contained in:
@@ -1,9 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { getAuthClient } from '@/api/auth_client';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { ref } from 'vue';
|
||||
import HeaderMenu from '@/components/HeaderMenu.vue'
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const client = getAuthClient();
|
||||
|
||||
const permissions = ref<string[]>([])
|
||||
|
||||
async function getPermissions() {
|
||||
permissions.value = []
|
||||
const res = await client.GetPermissions({})
|
||||
permissions.value = res.permissions!
|
||||
}
|
||||
|
||||
getPermissions()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="header">
|
||||
<p @click="goToLogout" class="btn-login">
|
||||
Выйти
|
||||
</p>
|
||||
</header>
|
||||
<HeaderMenu :add-logout="true"/>
|
||||
|
||||
<p>
|
||||
Доброго времени суток, {{ authStore.username }}.
|
||||
@@ -12,33 +28,7 @@
|
||||
{{ authStore.userRoles }}
|
||||
</p>
|
||||
|
||||
<button @click="getPermissions">Права</button>
|
||||
{{ permissions }}
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getAuthClient } from '@/api/auth_client';
|
||||
import router from '@/router';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { ref } from 'vue';
|
||||
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const client = getAuthClient()
|
||||
|
||||
const permissions = ref<string[]>([])
|
||||
|
||||
const goToLogout = () => {
|
||||
authStore.logout()
|
||||
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
async function getPermissions() {
|
||||
permissions.value = []
|
||||
const res = await client.GetPermissions({})
|
||||
permissions.value = res.permissions!
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user