header.vue 1.38 KB
<template>
  <div class="title_wrap">
    <div class="title_dir" v-show="isShowArrow" @click="arrowTo">
      <ArrowLeftBold class="title_arrow"/>
    </div>
    <div class="page_title">{{ title }}</div>
    <div v-show="false">{{ route.path }}</div>
  </div>
</template>

<script setup lang="ts">
import {ArrowLeftBold} from '@element-plus/icons-vue'
/*import * as api from "./../interface/login"
import {setToken} from "../utils/auth";
import { loginMain } from '../store/index'
import {storeToRefs} from "pinia";
let loginAct = loginMain()
let { getStoreToken } = storeToRefs(loginAct)*/

const route = useRoute();
let title = ref("");
let isShowArrow = ref(true)
let pathList = reactive(['/', '/product', '/mine'])
const emit = defineEmits(["arrowTo"]);

watchEffect(() => {
  let matched = route.matched.filter(item => item.meta && item.meta.title)
  if (matched[0]) {
    title = matched[0].meta.title
  }
  isShowArrow = true
  if (pathList.includes(route.path)) {
    isShowArrow = false
  }
})

let arrowTo = () => {
  emit('arrowTo')
}
</script>

<style scoped>
.title_wrap {
  position: relative;
}

.title_dir {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0;
}

.title_arrow {
  width: 20px;
}

.page_title {
  text-align: center;
  line-height: 50px;
  font-weight: bold;
  border-bottom: 1px #b6b6b6 solid;
  background-color: #ffffff;
}
</style>