Capital/components/UserMenu.vue

59 lines
1.7 KiB
Vue
Raw Permalink Normal View History

<template>
<v-menu>
<template #activator="{ props }">
<v-btn flat exact v-bind="props" icon>
<v-avatar v-if="id.isReady" color="transparent" icon="mdi-account-circle" :image="avatar" />
<v-progress-circular v-else indeterminate size="20" width="2.5" />
</v-btn>
</template>
<v-list density="compact" v-if="id.isLoggedIn">
<v-list-item :title="nickname" :subtitle="username" />
<v-divider class="border-opacity-50 my-2" />
<v-list-item :title="t('userMenuDashboard')" prepend-icon="mdi-account-supervisor" exact to="/users/me" />
<v-list-item :title="t('userMenuSignOut')" prepend-icon="mdi-logout" @click="signOut"></v-list-item>
</v-list>
<v-list density="compact" v-else>
<v-list-item :title="t('userMenuSignIn')" prepend-icon="mdi-login-variant" to="/auth/sign-in" />
<v-list-item :title="t('userMenuSignUp')" prepend-icon="mdi-account-plus" to="/auth/sign-up" />
</v-list>
</v-menu>
</template>
<script setup lang="ts">
2024-08-13 10:26:36 +00:00
import { useUserinfo } from "@/stores/userinfo"
import { computed } from "vue"
2024-09-22 10:00:14 +00:00
const { t } = useI18n()
const config = useRuntimeConfig()
const id = useUserinfo()
const username = computed(() => {
if (id.isLoggedIn) {
return "@" + id.userinfo?.name
} else {
return "@visitor"
}
})
const nickname = computed(() => {
if (id.isLoggedIn) {
return id.userinfo?.nick
} else {
return "Anonymous"
}
})
const avatar = computed(() => {
return id.userinfo?.avatar ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${id.userinfo?.avatar}` : void 0
})
2024-08-12 15:51:42 +00:00
function signOut() {
2024-09-22 10:00:14 +00:00
useAtk().value = null
useRtk().value = null
id.userinfo.value = null
2024-08-12 15:51:42 +00:00
reloadNuxtApp()
}
</script>