123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <script setup lang="ts">
- // import router from '@/router';
- import { ref } from 'vue'
- import { useRouter } from 'vue-router'
- const router = useRouter()
- import { menuStatusStore } from '@/stores';
- // import url from '../assets/home/trademark.png';
- //选中的索引
- const menuStatus = menuStatusStore()
- const activeIndex = ref<string>()
- activeIndex.value = menuStatus.activeIndex
- //选中菜单事件
- const handleSelect = (key: string, keyPath: []) => {
- console.log(key, keyPath)
- menuStatus.saveActiveIndex(key)
- activeIndex.value = key;
- if (key == '1') {
- router.push({ name: 'homeView' })
- } else if (key == '2') {
- router.push({ name: 'popularizationScience' })
- } else if (key == '3') {
- router.push({ name: 'community', })
- } else if (key == '4') {
- router.push({ name: 'plan', })
- } else if (key == '5') {
- router.push({ name: 'testRecord' })
- }
- // menuStatus.saveActiveIndex(key)
- }
- //点击登录按钮
- const login = () => {
- menuStatus.saveActiveIndex('6')
- router.push({ name: 'login', params: {} })
- }
- </script>
- <template>
- <div class="header_p">
- <div class="header_image">
- <img style="width: 239px; height: 55px" src="../assets/home/trademark.png"></img>
- </div>
- <el-menu :default-active="activeIndex" class="el-menu-demo" style="display: flex;" mode="horizontal"
- :ellipsis="false" @select="handleSelect">
- <el-menu-item index="1">首页</el-menu-item>
- <el-menu-item index="2">科普乐园</el-menu-item>
- <el-menu-item index="3">留言社区</el-menu-item>
- <!-- <el-badge :value="200" :max="99" class="item">
- <el-menu-item index="4">测试计划</el-menu-item>
- </el-badge> -->
- <el-menu-item index="4">
- <div class="badge_custom">
- 122
- </div>
- <span>测试计划</span>
- </el-menu-item>
- <el-menu-item index="5">测试记录</el-menu-item>
- </el-menu>
- <div class="login_button_bg" @click="login">
- <img width="20px" src="../assets/home/button_login.png" />
-
- <span>登录账号</span>
- </div>
- <!-- <div class="menu_gen">首页</div>
- <div class="menu_gen">科普乐园</div>
- <div class="menu_gen">留言社区</div>
- <div class="menu_gen">测试计划</div>
- <div class="menu_gen">测试记录</div>
- <div class="menu_gen">登录账号</div> -->
- </div>
- </template>
- <style lang="scss" scoped>
- .el-menu {
- background-color: transparent !important
- }
- .badge_custom {
- position: absolute;
- background-color: #48D68E;
- left: 90px;
- top: 0px;
- line-height: 18px;
- color: 10px;
- padding: 0px 8px;
- font-weight: 300;
- font-size: 10px;
- color: #ffffff;
- border-top-left-radius: 20px;
- border-top-right-radius: 20px;
- border-bottom-right-radius: 20px;
- }
- //整个菜单底部样式
- .el-menu--horizontal.el-menu {
- border-bottom: 0px solid var(--el-menu-border-color);
- display: flex;
- align-items: center;
- }
- .el-menu--horizontal>.el-menu-item {
- width: 120px;
- height: 40px;
- align-items: center;
- border-bottom: 0px solid transparent;
- color: var(--el-menu-text-color);
- display: inline-flex;
- // height: 100%;
- justify-content: center;
- align-items: center;
- border-radius: 12px;
- margin: 0;
- }
- .el-menu--horizontal .el-menu-item:not(.is-disabled):focus,
- .el-menu--horizontal .el-menu-item:not(.is-disabled):hover {
- background-color: #48D68E;
- color: #000000 !important;
- border-radius: 12px;
- }
- //激活某个菜单时 底部样式
- .el-menu--horizontal>.el-menu-item.is-active {
- border-bottom: 0px solid var(--el-menu-active-color);
- // color: var(--el-menu-active-color) !important;
- color: #000000 !important;
- background: #48D68E;
- border-radius: 12px;
- height: 40px;
- font-weight: 700;
- }
- .header_p {
- padding-top: 20px;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- .header_image {
- // flex: 1
- margin-right: 100px;
- }
- .login_button_bg {
- background-color: #000000;
- border-radius: 12px;
- border: 3px solid #48D68E;
- color: #ffffff;
- padding: 8px 20px;
- cursor: pointer;
- display: flex;
- align-items: center;
- }
- .flex-grow {
- flex: 1;
- }
- .menu_gen {
- width: 80px;
- height: 20px;
- font-family: Alibaba PuHuiTi 2.0;
- font-weight: normal;
- font-size: 20px;
- color: #333333;
- line-height: 26px
- }
- }
- </style>
|