From 81a132f7b5d022e8d55dc1fefe2a7357f5bcbafa Mon Sep 17 00:00:00 2001
From: 杨磊 <505174330@qq.com>
Date: 星期一, 25 八月 2025 15:22:27 +0800
Subject: [PATCH] 首页

---
 src/layout/components/headerPage.vue |  125 ++++++++++++++++++++++++++++++-----------
 1 files changed, 90 insertions(+), 35 deletions(-)

diff --git a/src/layout/components/headerPage.vue b/src/layout/components/headerPage.vue
index b4ec4ec..9a252cf 100644
--- a/src/layout/components/headerPage.vue
+++ b/src/layout/components/headerPage.vue
@@ -15,36 +15,46 @@
       </div>
       <div class="searchBox" v-show="!hideSerch">
         <el-input
-          style="width: 500px; height: 50px"
+          style="width: 500px; height: 36px"
           placeholder="璇疯緭鍏ュ唴瀹�"
-          @change="gotoSearch"
           v-model="searchKey"
           :suffix-icon="Search"
+          @keyup.enter="gotoSearch"
         >
         </el-input>
         <div class="loginInfoBox">
-          <div v-if="!userInfo" class="loginBtnBox">
-            <a
+          <div v-if="!userInfo" class="loginBtnBox" style="width: 200px">
+            <div
+              class="loginBtn"
               @click="
                 () => {
                   console.log(loginRef.value)
                   loginRef.logIn()
                 }
               "
-              >娉ㄥ唽/鐧诲綍</a
             >
+              <el-icon><UserFilled /></el-icon>
+              娉ㄥ唽/鐧诲綍
+            </div>
           </div>
           <div v-else class="userInfoBox">
             <el-dropdown @command="handleCommand">
-              <span style="cursor: pointer">娆㈣繋鎮紝{{ userStore?.userInfo.name }}锛�</span>
-              <el-dropdown-menu slot="dropdown">
-                <el-dropdown-item icon="el-icon-user" command="gotoPersonalCenter"
-                  >涓汉涓績</el-dropdown-item
-                >
-                <el-dropdown-item icon="el-icon-switch-button" command="logout"
-                  >閫�鍑虹櫥褰�</el-dropdown-item
-                >
-              </el-dropdown-menu>
+              <span class="el-dropdown-link">
+                娆㈣繋鎮紝{{ userStore?.userInfo.name }}锛�
+                <el-icon class="el-icon--right">
+                  <arrow-down />
+                </el-icon>
+              </span>
+              <template #dropdown>
+                <el-dropdown-menu>
+                  <el-dropdown-item :icon="Avatar" command="gotoPersonalCenter"
+                    >涓汉涓績</el-dropdown-item
+                  >
+                  <el-dropdown-item :icon="SwitchButton" command="logout"
+                    >閫�鍑虹櫥褰�</el-dropdown-item
+                  >
+                </el-dropdown-menu>
+              </template>
             </el-dropdown>
           </div>
         </div>
@@ -55,7 +65,8 @@
       <div
         :class="{
           navItem: true,
-          active: $route.fullPath.indexOf(item.path) > -1,
+          // active: $route.fullPath.indexOf(item.path) > -1,
+          active: item.pathList.findIndex((citem) => citem == $route.path) > -1,
         }"
         v-for="(item, index) in navData"
         :key="index"
@@ -69,12 +80,15 @@
 
 <script setup lang="ts">
 import login from './login.vue'
-import { onMounted, ref } from 'vue'
-import { Search } from '@element-plus/icons-vue'
-import { useUserStore } from '@/stores'
-import { useRouter } from 'vue-router'
+import { onMounted, provide, ref } from 'vue'
+import { Search, Avatar, SwitchButton } from '@element-plus/icons-vue'
+import { useUserStore } from '@/store'
+import { useRouter, useRoute } from 'vue-router'
+import { ElMessage } from 'element-plus'
+
 const userStore = useUserStore()
 const router = useRouter()
+const route = useRoute()
 
 const loginRef = ref()
 const props = defineProps({
@@ -94,30 +108,63 @@
   {
     name: '棣栭〉',
     path: '/home',
+    pathList: ['/home', '/search'],
   },
   {
     name: '鏁欒偛鍑虹増',
     path: '/bookStore',
+    pathList: ['/bookStore', '/bookdetail'],
   },
   {
     name: '璇昏�呮湇鍔�',
     path: '/teachingServices',
+    pathList: ['/teachingServices'],
   },
   {
     name: '鍏充簬鎴戜滑',
     path: '/aboutUs',
+    pathList: ['/aboutUs'],
   },
 ])
 
 onMounted(() => {
   userInfo.value = userStore.userInfo
   console.log(userInfo.value, 'userInfo')
+  console.log(route, 'route')
 })
 
-const gotoSearch = () => {}
-const handleCommand = () => {}
+const gotoSearch = () => {
+  router.push({
+    path: '/search',
+    query: {
+      key: searchKey.value,
+    },
+  })
+}
+const handleCommand = (item) => {
+  if (item === 'gotoPersonalCenter') {
+    router.push({
+      path: '/personalCenter',
+    })
+  }
+  if (item === 'logout') {
+    localStorage.clear()
+    userStore.delteUserInfo()
+    userInfo.value = null
+    router.push({
+      path: '/home',
+    })
+  }
+}
 const gotoPage = (item) => {
-  router.push(item.path)
+  if (item.path === '/teachingServices') {
+    ElMessage({
+      message: '寤鸿涓�...',
+      type: 'warning',
+    })
+  } else {
+    router.push(item.path)
+  }
 }
 </script>
 
@@ -125,7 +172,6 @@
 .pageHeader {
   width: 100%;
   background-color: #fff;
-  border-bottom: 1px solid #e6e6e6;
   .topBar {
     background: #e6e6e6;
     color: #808080;
@@ -134,16 +180,20 @@
     p {
       float: left;
     }
-    .loginInfoBox {
-      float: right;
-      .loginBtnBox {
-        a {
-          cursor: pointer;
-          text-decoration: none;
-          color: inherit;
-          margin: 0 4px;
-        }
-      }
+  }
+
+  .loginInfoBox {
+    width: 200px;
+    margin-left: 20px;
+    .loginBtn {
+      width: 100px;
+      background-color: #144941;
+      height: 36px;
+      line-height: 36px;
+      text-align: center;
+      border-radius: 20px;
+      color: #ffffff;
+      cursor: pointer;
     }
   }
   .logoBox {
@@ -162,9 +212,9 @@
       width: 670px;
       float: right;
       padding-right: 10px;
-      line-height: 66px;
       display: flex;
       justify-content: space-between;
+      align-items: center;
       .searchItem {
         width: 120px;
         vertical-align: initial;
@@ -195,9 +245,14 @@
   }
 }
 </style>
-<style>
+<style scoped>
 .pageHeader .searchBox .el-input-group__prepend {
   background: #fff;
   color: #444;
 }
+::v-deep(.el-input__wrapper) {
+  border-radius: 50px !important;
+  height: 36px;
+  line-height: 36px;
+}
 </style>

--
Gitblit v1.9.1