From 019abc739d9e231c2ebfe9ca537f82e2e1843496 Mon Sep 17 00:00:00 2001
From: QYF-GitLab1 <1940665526@qq.com>
Date: 星期日, 24 八月 2025 21:24:39 +0800
Subject: [PATCH] 课程班级显示

---
 src/layout/components/headerPage.vue |  135 ++++++++++++++++++++++++++++++--------------
 1 files changed, 91 insertions(+), 44 deletions(-)

diff --git a/src/layout/components/headerPage.vue b/src/layout/components/headerPage.vue
index c1664cb..a03c9ab 100644
--- a/src/layout/components/headerPage.vue
+++ b/src/layout/components/headerPage.vue
@@ -15,11 +15,11 @@
       </div>
       <div class="searchBox" v-show="!hideSerch">
         <el-input
-          style="width: 500px"
+          style="width: 500px; height: 50px"
           placeholder="璇疯緭鍏ュ唴瀹�"
-          @change="gotoSearch"
           v-model="searchKey"
           :suffix-icon="Search"
+          @keyup.enter="gotoSearch"
         >
         </el-input>
         <div class="loginInfoBox">
@@ -27,44 +27,37 @@
             <a
               @click="
                 () => {
-                  $router.push({
-                    path: '/register',
-                  })
+                  console.log(loginRef.value)
+                  loginRef.logIn()
                 }
               "
-              >娉ㄥ唽</a
-            >
-            |
-            <a
-              @click="
-                () => {
-                  $router.push({
-                    path: '/login',
-                    query: {
-                      redirectPath: $route.fullPath,
-                    },
-                  })
-                }
-              "
-              >鐧诲綍</a
+              >娉ㄥ唽/鐧诲綍</a
             >
           </div>
           <div v-else class="userInfoBox">
             <el-dropdown @command="handleCommand">
-              <span style="cursor: pointer">娆㈣繋鎮紝{{ 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>
       </div>
     </div>
+    <login ref="loginRef"></login>
     <div class="contentBox navBox" v-show="!hideNav">
       <div
         :class="{
@@ -82,8 +75,16 @@
 </template>
 
 <script setup lang="ts">
-import { ref } from 'vue'
+import login from './login.vue'
+import { onMounted, provide, ref } from 'vue'
+import { Search, Avatar, SwitchButton } from '@element-plus/icons-vue'
+import { useUserStore } from '@/store'
+import { useRouter } from 'vue-router'
+import { ElMessage } from 'element-plus'
+const userStore = useUserStore()
+const router = useRouter()
 
+const loginRef = ref()
 const props = defineProps({
   hideSerch: {
     type: Boolean,
@@ -97,9 +98,61 @@
 
 let searchKey = ref('')
 let userInfo = ref('')
+const navData = ref([
+  {
+    name: '棣栭〉',
+    path: '/home',
+  },
+  {
+    name: '鏁欒偛鍑虹増',
+    path: '/bookStore',
+  },
+  {
+    name: '璇昏�呮湇鍔�',
+    path: '/teachingServices',
+  },
+  {
+    name: '鍏充簬鎴戜滑',
+    path: '/aboutUs',
+  },
+])
 
-const gotoSearch = () => {}
-const handleCommand = () => {}
+onMounted(() => {
+  userInfo.value = userStore.userInfo
+  console.log(userInfo.value, 'userInfo')
+})
+
+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()
+    router.push({
+      path: '/home',
+    })
+  }
+}
+const gotoPage = (item) => {
+  if (item.path === '/teachingServices') {
+    ElMessage({
+      message: '寤鸿涓�...',
+      type: 'warning',
+    })
+  } else {
+    router.push(item.path)
+  }
+}
 </script>
 
 <style lang="less" scoped>
@@ -115,17 +168,11 @@
     p {
       float: left;
     }
-    .loginInfoBox {
-      float: right;
-      .loginBtnBox {
-        a {
-          cursor: pointer;
-          text-decoration: none;
-          color: inherit;
-          margin: 0 4px;
-        }
-      }
-    }
+  }
+
+  .loginInfoBox {
+    width: 200px;
+    margin-left: 20px;
   }
   .logoBox {
     padding: 25px 0;
@@ -143,9 +190,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;

--
Gitblit v1.9.1