Commit 51026394 authored by nick zheng's avatar nick zheng

chore: 用户未登录时支持跳转登录页

parent 72d05b9b
......@@ -53,6 +53,13 @@ function handleDropdownSelect(key: string) {
router.replace({ name: key })
}
function handleToLogin() {
router.push({
name: 'Login',
query: { redirect: encodeURIComponent(router.currentRoute.value.fullPath) },
})
}
</script>
<template>
......@@ -87,7 +94,13 @@ function handleDropdownSelect(key: string) {
</div>
<div class="mb-7">
<NDropdown trigger="click" placement="top-start" :options="avatarOptions" @select="handleDropdownSelect">
<NDropdown
v-if="userStore.isLogin"
trigger="click"
placement="top-start"
:options="avatarOptions"
@select="handleDropdownSelect"
>
<div class="flex h-full cursor-pointer items-center">
<NAvatar round :size="40" object-fit="cover" :src="userStore.userInfo.avatarUrl || defaultAvatar" />
......@@ -96,6 +109,10 @@ function handleDropdownSelect(key: string) {
</div>
</div>
</NDropdown>
<div v-else>
<NButton type="primary" class="w-full! rounded-md!" @click="handleToLogin">立即登录</NButton>
</div>
</div>
</div>
</template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment