Files
Yi.Admin/Yi.BBS.Vue3/src/layout/AppHeader.vue

89 lines
2.5 KiB
Vue
Raw Normal View History

2023-03-03 21:58:58 +08:00
<template>
<el-menu
:default-active="activeIndex"
class="el-menu-demo"
mode="horizontal"
:ellipsis="false"
2023-03-03 21:58:58 +08:00
@select="handleSelect"
2023-03-05 20:30:44 +08:00
2023-03-03 21:58:58 +08:00
>
2023-03-17 00:30:26 +08:00
<el-menu-item class="logo" index="" @click="enterIndex" >
<img class="img-icon" style="width: 35px; height: 35px" src="@/assets/logo.ico" />Yi意社区</el-menu-item>
<el-menu-item index="1" @click="enterIndex">主页</el-menu-item>
2023-03-03 21:58:58 +08:00
<el-sub-menu index="2">
2023-03-05 20:30:44 +08:00
<template #title>学习</template>
2023-03-10 22:02:19 +08:00
<el-menu-item index="2-1">学习 one</el-menu-item>
<el-menu-item index="2-2">学习 two</el-menu-item>
<el-menu-item index="2-3">学习 three</el-menu-item>
2023-03-03 21:58:58 +08:00
</el-sub-menu>
2023-03-05 20:30:44 +08:00
<el-sub-menu index="3">
<template #title>资源</template>
2023-03-10 22:02:19 +08:00
<el-menu-item index="3-1">资源 one</el-menu-item>
<el-menu-item index="3-2">资源 two</el-menu-item>
<el-menu-item index="3-3">资源 three</el-menu-item>
2023-03-05 20:30:44 +08:00
</el-sub-menu>
<el-sub-menu index="4">
<template #title>问答</template>
2023-03-10 22:02:19 +08:00
<el-menu-item index="4-1">问答 one</el-menu-item>
<el-menu-item index="4-2">问答 two</el-menu-item>
<el-menu-item index="4-3">问答 three</el-menu-item>
2023-03-05 20:30:44 +08:00
</el-sub-menu>
<div class="flex-grow" />
<el-menu-item index="5">
2023-03-19 00:42:18 +08:00
<div style="width: 350px;">
<el-input style="width: 300px;" placeholder="全站搜索" clearable prefix-icon="Search" />
<el-button type="primary" plain>搜索</el-button>
</div>
</el-menu-item>
<el-menu-item index="6" @click="enterProfile" >
2023-03-17 00:30:26 +08:00
<AvatarInfo :size='30' :isSelf="true" />
</el-menu-item>
<el-sub-menu index="6">
2023-03-16 21:34:52 +08:00
<template #title>个人中心</template>
2023-03-17 00:30:26 +08:00
<el-menu-item index="6-1">学习 one</el-menu-item>
<el-menu-item index="6-2">学习 two</el-menu-item>
<el-menu-item index="6-3" @click="logout">登出</el-menu-item>
2023-03-05 20:30:44 +08:00
</el-sub-menu>
2023-03-16 21:34:52 +08:00
2023-03-03 21:58:58 +08:00
</el-menu>
</template>
<script setup>
2023-03-17 00:30:26 +08:00
import AvatarInfo from '@/components/AvatarInfo.vue'
2023-03-03 21:58:58 +08:00
import { ref } from 'vue'
2023-03-05 20:30:44 +08:00
import { useRouter } from 'vue-router'
2023-03-16 21:34:52 +08:00
import useUserStore from '@/stores/user.js'
2023-03-05 20:30:44 +08:00
const router = useRouter()
2023-03-16 21:34:52 +08:00
const userStore =useUserStore();
2023-03-03 21:58:58 +08:00
const activeIndex = ref('1')
const handleSelect = (key, keyPath) => {
console.log(key, keyPath)
}
2023-03-16 21:34:52 +08:00
const logout=async ()=>{
await userStore.logOut();
router.push("/login");
}
2023-03-17 00:30:26 +08:00
const enterIndex=()=>{
router.push("/index");
};
2023-03-19 00:42:18 +08:00
const enterProfile=()=>{
router.push("/profile");}
2023-03-05 20:30:44 +08:00
</script>
<style scoped>
.logo{
min-width: 14rem;
2023-03-07 00:02:48 +08:00
font-size: large;
font-weight: 600;
2023-03-05 20:30:44 +08:00
}
.flex-grow {
flex-grow: 1;
}
2023-03-07 00:02:48 +08:00
.img-icon
{
margin-right: 0.5rem;
}
2023-03-05 20:30:44 +08:00
</style>