header.vue 2.24 KB
<script setup lang="ts">
/**
 * 公共布局头部组件
 * @module Header
 * @author Tengxi
 */
import { getCurrentInstance } from "vue";
import * as store from "@/pinia/index";
import { Fold, Expand } from "@element-plus/icons-vue";
import styles from '@/style/global.module.scss';
// TIP 获取全局变量,暂时只有坏图片占位图
const {
  appContext: {
    config: { globalProperties },
  },
} = getCurrentInstance();
// TIP 侧边菜单collapse状态切换
const toggleMenu = () => {
  store.family.appStore().toggleCollapse();
};
</script>

<template>
  <div class="header-container clearfix">
    <!-- TIP logo -->
    <div class="left-logo" :class="store.family.appStore().isCollapse? 'thinLogo': 'fatLogo'">
      <router-link to="/">
        <el-image
          :src="globalProperties.$cnliveLogo"
          fit="contain"
          style="height: 40px"
        ></el-image>
      </router-link>
    </div>
    <!-- TIP logo结束 -->
    <!-- TIP 控制菜单collapse的按钮 -->
    <div class="menu-collapse-button" @click="toggleMenu">
      <Expand class="font-style" v-if="store.family.appStore().isCollapse" />
      <Fold class="font-style" v-if="!store.family.appStore().isCollapse" />
    </div>
    <!-- TIP 控制菜单collapse的按钮结束 -->
    <!-- TIP 功能键 -->
    <div class="right-buttons">
      <el-button type="text">站内消息</el-button>
      <el-button type="text"><router-link to="/">首页</router-link></el-button>
      <el-button type="text">帮助</el-button>
      <el-button type="text">用户:管理员</el-button>
      <el-button type="text">退出</el-button>
    </div>
    <!-- TIP 功能键结束 -->
  </div>
</template>

<style scoped lang="scss">
.header-container {
  padding: 0 20px 0 0;
  height: 60px;
  top: 0;
  position: fixed;
  z-index: 1000;
  width: 100%;
  line-height: 60px;
  background-color: white;
  box-shadow: 0 1px 4px rgba(0,21,41,.08);
  .left-logo {
    float: left;
    margin-top: 10px;
    text-align: center;
  }
  .menu-collapse-button {
    float: left;
    margin-left: 20px;
    cursor: hand;
    cursor: pointer;
    .font-style {
      width: 1.2em;
      height: 1.2em;
      margin-right: 8px;
      margin-top: 20px;
    }
  }
  .right-buttons {
    float: right;
  }
}
</style>