From 5f00696dfb25bc90034448ceb634ed1ef256681a Mon Sep 17 00:00:00 2001 From: qiyunfeng-create <1940665526@qq.com> Date: 星期四, 21 八月 2025 21:13:35 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/xiehe_website --- src/layout/components/headerPage.vue | 115 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 64 insertions(+), 51 deletions(-) diff --git a/src/layout/components/headerPage.vue b/src/layout/components/headerPage.vue index b4ec4ec..9aa7fcd 100644 --- a/src/layout/components/headerPage.vue +++ b/src/layout/components/headerPage.vue @@ -7,7 +7,7 @@ () => { $router.push({ path: '/home', - }) + }); } " src="@/assets/images/xiehe/home/Group_303.png" @@ -27,8 +27,8 @@ <a @click=" () => { - console.log(loginRef.value) - loginRef.logIn() + console.log(loginRef.value); + loginRef.logIn(); } " >娉ㄥ唽/鐧诲綍</a @@ -36,15 +36,22 @@ </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="el-icon-user" command="gotoPersonalCenter" + >涓汉涓績</el-dropdown-item + > + <el-dropdown-item icon="el-icon-switch-button" command="logout" + >閫�鍑虹櫥褰�</el-dropdown-item + > + </el-dropdown-menu> + </template> </el-dropdown> </div> </div> @@ -68,15 +75,15 @@ </template> <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' -const userStore = useUserStore() -const router = useRouter() +import login from "./login.vue"; +import { onMounted, ref } from "vue"; +import { Search } from "@element-plus/icons-vue"; +import { useUserStore } from "@/store"; +import { useRouter } from "vue-router"; +const userStore = useUserStore(); +const router = useRouter(); -const loginRef = ref() +const loginRef = ref(); const props = defineProps({ hideSerch: { type: Boolean, @@ -86,39 +93,51 @@ type: Boolean, default: false, }, -}) +}); -let searchKey = ref('') -let userInfo = ref('') +let searchKey = ref(""); +let userInfo = ref(""); const navData = ref([ { - name: '棣栭〉', - path: '/home', + name: "棣栭〉", + path: "/home", }, { - name: '鏁欒偛鍑虹増', - path: '/bookStore', + name: "鏁欒偛鍑虹増", + path: "/bookStore", }, { - name: '璇昏�呮湇鍔�', - path: '/teachingServices', + name: "璇昏�呮湇鍔�", + path: "/teachingServices", }, { - name: '鍏充簬鎴戜滑', - path: '/aboutUs', + name: "鍏充簬鎴戜滑", + path: "/aboutUs", }, -]) +]); onMounted(() => { - userInfo.value = userStore.userInfo - console.log(userInfo.value, 'userInfo') -}) + userInfo.value = userStore.userInfo; + console.log(userInfo.value, "userInfo"); +}); -const gotoSearch = () => {} -const handleCommand = () => {} +const gotoSearch = () => {}; +const handleCommand = (item) => { + if (item === "gotoPersonalCenter") { + router.push({ + path: "/personalCenter", + }); + } + if (item === "logout") { + localStorage.clear(); + router.push({ + path: "/home", + }); + } +}; const gotoPage = (item) => { - router.push(item.path) -} + router.push(item.path); +}; </script> <style lang="less" scoped> @@ -134,17 +153,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; @@ -162,9 +175,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