1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-04 16:09:59 +00:00

ui: go self profile on user switcher

This commit is contained in:
三咲智子 2022-11-28 15:03:26 +08:00
parent 871076f2d9
commit 5e0119aa84
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E

View file

@ -1,4 +1,6 @@
<script setup lang="ts">
import type { UserLogin } from '~~/types'
const all = useUsers()
const sorted = computed(() => {
@ -7,21 +9,27 @@ const sorted = computed(() => {
...all.value.filter(account => account.token !== currentUser.value?.token),
].filter(Boolean)
})
const router = useRouter()
const switchUser = (user: UserLogin) => {
if (user.account.id === currentUser.value?.account.id)
router.push(getAccountPath(user.account))
else loginTo(user)
}
</script>
<template>
<div min-w-80 mxa py2 flex="~ col">
<template v-for="user of sorted" :key="user.id">
<Component
:is="user.token !== currentUser?.token ? 'button' : 'div'"
<button
flex rounded px4 py3 text-left
:class="user.token !== currentUser?.token ? 'hover:bg-active cursor-pointer transition-100' : ''"
@click="loginTo(user)"
hover:bg-active cursor-pointer transition-100
@click="switchUser(user)"
>
<AccountInfo :account="user.account" />
<div flex-auto />
<div v-if="user.token === currentUser?.token" i-ri:check-line text-primary mya text-2xl />
</Component>
</button>
</template>
<div border="t base" pt2>
<button btn-text flex="~ gap-1" items-center @click="openSigninDialog">