<!--<template>-->
<!--  <div style=" height: 70px; width: 1248px; display: flex;-->
<!--      justify-content: space-between; align-items: center;">-->
<!--    <div style=" display: flex; justify-content: center;-->
<!--        align-items: center; margin-left: 10px">-->
<!--      <el-icon @click="changeState" v-show="showLog" size="20px" style="margin-right: 10px"><Expand/></el-icon>-->
<!--      <el-icon @click="changeState" v-show="!showLog" size="20px" style="margin-right: 10px"><Fold /></el-icon>-->


<!--      <el-breadcrumb separator="/">-->
<!--        <el-breadcrumb-item :to="{ path: currentPath}">{{ strArr[0] }}</el-breadcrumb-item>-->
<!--        <el-breadcrumb-item><a :href="currentPath">{{ strArr[1] }}</a></el-breadcrumb-item>-->
<!--      </el-breadcrumb>-->
<!--    </div>-->

<!--    <div :style="{display: 'flex', justifyContent:'center', alignItems: 'center', marginRight: offset + 'px'}">-->
<!--      <el-avatar style="margin-right: 10px">-->
<!--        <img src="../assets/admin.jpg" alt="">-->
<!--      </el-avatar>-->

<!--      <el-dropdown style="cursor: pointer;" size="default">-->
<!--            <span class="el-dropdown-link" style="font-size: 16px; font-weight: bold;">-->
<!--              <span>{{ currentUser.username }}</span><el-icon class="el-icon&#45;&#45;right"><arrow-down /></el-icon>-->
<!--            </span>-->
<!--        <template #dropdown>-->
<!--          <el-dropdown-menu>-->
<!--            <el-dropdown-item @click="$router.push('/manage/person')">个人信息</el-dropdown-item>-->
<!--            <el-dropdown-item @click="logout">退出登录</el-dropdown-item>-->
<!--          </el-dropdown-menu>-->
<!--        </template>-->
<!--      </el-dropdown>-->
<!--    </div>-->
<!--  </div>-->
<!--</template>-->

<!--<script setup lang="ts">-->
<!--import {computed, onMounted, ref} from 'vue'-->
<!--import emitter from '@/utils/emitter'-->
<!--import { useRouter} from 'vue-router';-->
<!--import { ElMessage } from 'element-plus';-->
<!--import { pathInfo } from '@/store/pathInfo'-->
<!--const pathStore = pathInfo()-->
<!--const strArr = computed(() => pathStore.currentPathName.split('/'))-->
<!--const currentPath = computed(() => pathStore.currentPath)-->

<!--const router = useRouter()-->
<!--const offset = ref(20)-->
<!--const showLog = ref(false)-->
<!--const currentUser = ref('')-->

<!--onMounted(() => {-->
<!--  currentUser.value = JSON.parse(localStorage.getItem('user'))-->
<!--})-->




<!--const changeState = () => {-->
<!--  showLog.value = !showLog.value-->
<!--  emitter.emit('Aside', showLog.value)-->
<!--  if(showLog.value){-->
<!--    offset.value = -116-->
<!--  }else{-->
<!--    offset.value = 20-->
<!--  }-->
<!--}-->

<!--const logout = () => {-->
<!--  ElMessage({-->
<!--    message: '退出成功',-->
<!--    type: 'success'-->
<!--  })-->
<!--  router.push('/login')-->
<!--  localStorage.removeItem('user')-->
<!--}-->

<!--</script>-->

<!--<style scoped>-->
<!--:deep(.el-tooltip__trigger:focus-visible) {-->
<!--  outline: unset;-->
<!--}-->

<!--</style>-->
<template>
  <div style=" height: 70px; width: 1248px; display: flex;
      justify-content: space-between; align-items: center;">
    <div style=" display: flex; justify-content: center;
        align-items: center; margin-left: 10px">
      <el-icon @click="changeState" v-show="showLog" size="20px" style="margin-right: 10px">
        <Expand />
      </el-icon>
      <el-icon @click="changeState" v-show="!showLog" size="20px" style="margin-right: 10px">
        <Fold />
      </el-icon>


      <el-breadcrumb separator="/">
        <a-breadcrumb-item>{{ route.name }}</a-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <div :style="{ display: 'flex', justifyContent: 'center', alignItems: 'center', marginRight: offset + 'px' }">
      <el-avatar style="margin-right: 10px">
        <img :src="store.loginUser.userAvatar" alt="">
      </el-avatar>

      <el-dropdown style="cursor: pointer;" size="default">
        <span class="el-dropdown-link" style="font-size: 16px; font-weight: bold;">
          <span>{{ store.loginUser.userName }}</span><el-icon class="el-icon--right"><arrow-down /></el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="$router.push('/PersonalCenter')">个人信息</el-dropdown-item>
            <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import emitter from '@/utils/emitter'
import { useRoute, useRouter } from "vue-router";
import myAxios from '@/api/myAxios';
import { userStore } from '@/store/userStore';
import { ElMessage } from 'element-plus';

const router = useRouter();
const route = useRoute();
const offset = ref(20)
const showLog = ref(false)
const store = userStore()


const logout = async () => {
  const res: any = await myAxios.post("/user/logout", {})
  if (res.data.code == 1 && res.data) {
    store.$reset()
    await router.replace('/')
    ElMessage({
      type: 'info',
      message: '登出成功',
    })
  }
}
const changeState = () => {
  showLog.value = !showLog.value
  emitter.emit('Aside', showLog.value)
  if (showLog.value) {
    offset.value = -116
  } else {
    offset.value = 20
  }
}

</script>

<style scoped>
:deep(.el-tooltip__trigger:focus-visible) {
  outline: unset;
}
</style>