Browse Source

回退Header.vue

master
wxc 2 years ago
parent
commit
fc2339cd21
  1. 117
      src/layout/components/Header.vue

117
src/layout/components/Header.vue

@ -4,46 +4,37 @@
<a href="/"> <a href="/">
<img src="/logo.png" alt="" /> <img src="/logo.png" alt="" />
</a> </a>
<span>长沙市公安局局长信箱即接即办系统</span> <span>长沙市公安局局长信箱即接即办平台</span>
</div> </div>
<NoticeMessage /> <NoticeMessage />
<div class="flex v-center gap-16"> <section class="flex gap userinfo v-center pointer" @click.stop="dropdownShow = true">
<section class="flex gap" :title="userStore.userInfo.roleName"> <icon name="el-icon-UserFilled" :size="29" color="#586EFF" />
<icon name="el-icon-UserFilled" :size="29" color="#586EFF" /> <span>{{ userStore.userInfo.fullName }}</span>
<span>{{ </section>
userStore.userInfo.deptName + " " + userStore.userInfo.name
}}</span>
<div class="dropdown-content">
<div><img src="/imgs/lock.png" style="width: 1.2vw;">&nbsp;&nbsp;&nbsp;<a @click="handleEdit">重置密码</a></div>
<div><img src="/imgs/goout.png" style="width: 1.2vw;">&nbsp;&nbsp;&nbsp;<a @click="logout">退出登录</a></div>
</div>
</section>
<el-button type="primary" @click="logout" style=""
>退出
<template #icon
><icon name="local-icon-logout" color="#586EFF"
/></template>
</el-button>
</div>
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
</header> </header>
<ul class="userinfo-dropdown" v-if="dropdownShow">
<li class="flex gap v-center" >
<icon name="el-icon-Lock" :size="22" />
<span>修改密码</span>
</li>
<li class="flex gap v-center" @click="handleLogout">
<icon name="local-icon-logout" :size="22" />
<span>退出登录</span>
</li>
</ul>
</template> </template>
<script lang="ts" setup> <script setup>
import NoticeMessage from "./NoticeMessage.vue"; import NoticeMessage from "./NoticeMessage.vue";
import useUserStore from "@/stores/modules/user"; import useUserStore from "@/stores/modules/user";
import NoticeMessageVue from "./NoticeMessage.vue";
import EditPopup from './edit.vue'
const userStore = useUserStore(); const userStore = useUserStore();
const editRef = shallowRef<InstanceType<typeof EditPopup>>(); const dropdownShow = ref(false)
const showEdit = ref(false)
const handleEdit = async () => { document.addEventListener("click", () => {
showEdit.value = true dropdownShow.value = false;
await nextTick() })
editRef.value?.open('edit')
} function handleLogout() {
function logout() {
userStore.logout(); userStore.logout();
} }
</script> </script>
@ -58,7 +49,6 @@ header {
font-size: 3.89vh; font-size: 3.89vh;
font-weight: 700; font-weight: 700;
letter-spacing: 4px; letter-spacing: 4px;
a { a {
text-decoration: none; text-decoration: none;
color: inherit; color: inherit;
@ -68,49 +58,28 @@ header {
} }
} }
} }
.gap{ .userinfo {
position: relative;/* 设置相对定位 */ margin-right: 8px;
display: inline-block;/* 让元素具有块级元素和行内元素的特性,即将块级元素转化为内联元素 */ }
.dropdown-content {
border-radius: 20px 20px 20px 20px;
display: none;
position: absolute;
background-color: #f9f9f9;
z-index: 100;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
a{
display: inline-block;
z-index: 289;
color: black;
font-size: 2.4vh;
cursor:pointer;
}
}
}
.gap:hover .dropdown-content {
display: block;
}
.nav2 a {
color: black;
padding: 12px 16px;
display: block;/* 将a标签设置为块级标签 */
}
.gap:hover .nav2 {
display: block;
} }
.el-button { .userinfo-dropdown {
--el-font-size-base: 18px; position: fixed;
--el-button-bg-color: #283aac; right: 16px;
--el-button-border-color: #586eff; top: calc(var(--header-height) - 8px);
height: 36px; background: #FFFFFF;
box-shadow: 0px 9px 28px 8px rgba(0,0,0,0.05), 0px 6px 16px 0px rgba(0,0,0,0.08), 0px 3px 6px -4px rgba(0,0,0,0.12);
border-radius: 8px;
margin: 0;
padding: 12px 0;
z-index: 999;
overflow: hidden;
li {
padding: 12px 16px;
font-size: 16px;
&:hover { &:hover {
--el-button-hover-bg-color: var(--el-button-bg-color); cursor: pointer;
--el-button-hover-border-color: #fff; font-weight: 700;
color: var(--primary-color);
} }
} }
} }

Loading…
Cancel
Save