123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <template>
- <a-layout-header class="header-layout">
- <div class="content-layout">
- <h2><img :src="logoPng" /></h2>
- <a-dropdown placement="bottomRight">
- <template #overlay>
- <a-menu style="width: 100px" @click="handlerMenuClick">
- <a-menu-item v-for="menu in menus" :key="menu.key">
- {{ menu.label }}
- </a-menu-item>
- </a-menu>
- </template>
- <div class="avatar">
- <a-avatar :size="32">
- <template #icon>
- <img :src="userStore.current.avatar" />
- </template>
- </a-avatar>
- <span>
- {{ userStore.current.nickname }}
- <DownOutlined />
- </span>
- </div>
- </a-dropdown>
- </div>
- </a-layout-header>
- </template>
- <script lang="ts" setup>
- import { MenuProps } from 'ant-design-vue'
- import { useUserStore } from '@/store'
- import { postLogout } from '@/api'
- import { mainURL } from '@/env'
- import logoPng from '@/assets/images/logo.png'
- defineOptions({ name: 'LayoutHeader' })
- const userStore = useUserStore()
- userStore.fetch()
- const menus = [
- { label: '个人中心', key: 'user' },
- { label: '退出', key: 'logout' }
- ]
- const handlerMenuClick: MenuProps['onClick'] = async e => {
- if (e.key === 'logout') {
- await postLogout()
- location.replace(mainURL)
- } else {
- location.href = `${mainURL}/#/information`
- }
- }
- </script>
- <style lang="scss" scoped>
- .header-layout {
- background-color: #fff;
- display: flex;
- padding: 0;
- h2 {
- margin: 0;
- img {
- width: 130px;
- }
- }
- }
- .content-layout {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .avatar {
- display: flex;
- align-items: center;
- cursor: pointer;
- > span {
- margin-left: 8px;
- }
- }
- </style>
|