123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <template>
- <div class="commonHeader">
- <div style="width: 155px">
- <svg-icon v-if="routeMeta.back" icon-class="back" size="48" @click="commonBack" />
- <!-- <svg-icon v-else icon-class="LOGO" style="height: 48px; width: 155px" /> -->
- </div>
- <div v-if="routeMeta.back && routeMeta.title" class="middle-title">
- {{ routeMeta.title }}
- </div>
- <div v-else>
- <div class="date">{{ date }}</div>
- <div class="time">{{ time }}</div>
- </div>
- <div>
- <el-space>
- <div>
- <svg-icon @click="messageStatus = !messageStatus" icon-class="lingdang" size="48" class="activeNotice" />
- </div>
- <div class="task">
- <el-progress :percentage="processCount" :show-text="false" :stroke-width="10" />
- <div class="process">任务进度: {{ processCount }}%</div>
- </div>
- <div>
- <div class="name">{{ userStore.user.username }}</div>
- <div class="work">{{ userStore.user.station }}</div>
- </div>
- <el-dropdown ref="dropdown1" trigger="contextmenu" @command="handleCommand">
- <img v-if="userStore.user.avatar" :alt="userStore.user.avatar" :src="userStore.user.avatar" object-fit="cover"
- style="width: 48px; height: 48px; border-radius: 24px" @click="showClick" />
- <svg-icon v-else icon-class="head" size="48" @click="showClick" />
- <template #dropdown>
- <el-dropdown-menu style="width: 150px">
- <!-- <el-dropdown-item command="a">Action 1</el-dropdown-item>-->
- <el-dropdown-item command="b">退出登录</el-dropdown-item>
- <!-- <el-dropdown-item command="c" divided>Action 3</el-dropdown-item>-->
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </el-space>
- </div>
- <MessageBox v-model="messageStatus" />
- </div>
- </template>
- <script lang="ts" setup>
- import dayjs from "dayjs";
- import type { DropdownInstance } from "element-plus";
- import { logoutApi } from "@/api/auth";
- import { useUserStore } from "@/store";
- const userStore = useUserStore();
- const router = useRouter();
- const route = useRoute();
- const routeMeta = computed(() => {
- return route.meta;
- });
- const dropdown1 = ref<DropdownInstance>();
- const date = dayjs().format("YYYY-MM-DD");
- const time = ref(dayjs().format("HH:mm:ss"));
- const processCount = ref(50);
- const messageStatus = ref(false);
- const headUrl = ref("");
- let timer: any = -1;
- onMounted(() => {
- timer = setInterval(() => {
- time.value = dayjs().format("HH:mm:ss");
- }, 1000);
- });
- onBeforeUnmount(() => {
- if (timer) {
- clearInterval(timer);
- }
- });
- const showClick = () => {
- if (!dropdown1.value) return;
- dropdown1.value.handleOpen();
- };
- const commonBack = (itemValue) => {
- router.back();
- };
- const handleCommand = (command: string | number | object) => {
- if (command === "b") {
- logoutApi().then(() => {
- localStorage.setItem("token", "");
- location.reload();
- });
- }
- };
- </script>
- <style lang="scss" scoped>
- :deep(.el-dropdown-menu__item) {
- height: 60px;
- display: flex;
- align-items: center;
- justify-content: center;
- font-weight: 500;
- font-size: 24px;
- color: rgba(0, 0, 0, 0.9);
- }
- .commonHeader {
- height: $navbar-height;
- width: 100%;
- background-color: #f1f3f5;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 16px 24px;
- //border: 1px solid red;
- .middle-title {
- font-weight: 500;
- font-size: 38px;
- color: rgba(0, 0, 0, 0.9);
- line-height: 24px;
- text-align: center;
- }
- .date {
- font-weight: 500;
- font-size: 14px;
- color: rgba(0, 0, 0, 0.6);
- line-height: 14px;
- text-align: center;
- }
- .time {
- font-weight: 500;
- font-size: 20px;
- color: rgba(0, 0, 0, 0.9);
- line-height: 23px;
- }
- .head {
- width: 48px;
- height: 48px;
- border-radius: 24px;
- }
- .name {
- font-weight: 500;
- font-size: 20px;
- color: rgba(0, 0, 0, 0.9);
- line-height: 14px;
- text-align: right;
- }
- .work {
- font-weight: 500;
- font-size: 14px;
- color: rgba(0, 0, 0, 0.6);
- line-height: 14px;
- text-align: right;
- margin-top: 5px;
- }
- .task {
- padding-top: 5px;
- margin-right: 10px;
- }
- // .activeNotice {
- // animation: swing 0.15s infinite alternate ease-in-out;
- // }
- // @keyframes swing {
- // 0% {
- // transform: rotate(-45deg);
- // }
- // 100% {
- // transform: rotate(45deg);
- // }
- // }
- .process {
- font-weight: 500;
- font-size: 14px;
- color: rgba(0, 0, 0, 0.6);
- line-height: 14px;
- text-align: right;
- margin-top: 8px;
- }
- }
- </style>
|