-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update Header component to include logout functionality
- Loading branch information
1 parent
78325f4
commit 87b2122
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,44 @@ | ||
<script setup lang="ts"> | ||
import type { PopconfirmProps } from 'tdesign-vue-next' | ||
import { useStoreLogin } from '~/stores/useStoreLogin' | ||
const router = useRouter() | ||
function onClickLogo() { | ||
router.push('/') | ||
} | ||
const visiblePopConfirmLogout = ref(false) | ||
const onClickLogout: PopconfirmProps['onVisibleChange'] = function (val, context = {}) { | ||
if (context && context.trigger === 'confirm') { | ||
const storeLogin = useStoreLogin() | ||
storeLogin.logout() | ||
visiblePopConfirmLogout.value = false | ||
router.push('/') | ||
} | ||
else { | ||
visiblePopConfirmLogout.value = val | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<t-header class="flex justify-between items-center p-x-10px"> | ||
<t-header class="flex justify-between items-center p-x-10px h-full"> | ||
<div class="flex items-center space-x-10px cursor-pointer" @click="onClickLogo"> | ||
<img src="/icon-128x128.png" alt="Cloudflare R2" class="w-30px h-30px"> | ||
<h1 class="text-base"> | ||
Oh Cloudflare R2 | ||
</h1> | ||
</div> | ||
|
||
<SwitchTheme class="w-40px" /> | ||
<div class="flex justify-center items-center space-x-10px"> | ||
<t-popconfirm | ||
:visible="visiblePopConfirmLogout" | ||
theme="default" | ||
placement="bottom" | ||
content="Are you sure you want to logout?" | ||
@visible-change="onClickLogout" | ||
> | ||
<Icon name="material-symbols:power-settings-circle" class="text-6" /> | ||
</t-popconfirm> | ||
<SwitchTheme class="w-30px" /> | ||
</div> | ||
</t-header> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.