index.vue 2.3 KB
<!--
 * @Description: 
 * @Author: huyue
 * @Date: 2024-07-24 17:47:51
 * @LastEditors: huyue
 * @LastEditTime: 2024-07-30 18:24:24
-->
<script lang="ts" setup>
import { inject, reactive } from 'vue'
import { useRouter } from 'vue-router';
// 获取全局对象
const global: any = inject("global");
const router = useRouter();
const userInfo = reactive({
  account: '管理员'
})

const logout = () => {
  router.replace({ path: '/login' })
  console.log('退出登录')
}
const getImageUrl = (name: any) => {
  return new URL(`./images/${name}.png`, global.$imgUrl).href;
};
</script>

<template>
  <div class="navbar">
    <div class="navbar-left">
      <a-image class="logo" width="32" :src="getImageUrl('layout-logo')" :preview="false" />
      <div class="title">广联数科控股有限公司</div>
    </div>
    <div class="navbar-right">
      <div class="avatar">{{ userInfo.account.slice(0, 1)}}</div>
      <div class="username">{{userInfo.account}}</div>
      <a-popover position="br" content-class="logout-popover">
        <icon-down />
        <template #content>
          <a-button @click="logout">退出登录</a-button>
        </template>
      </a-popover>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.navbar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  height: 48px;
  background-color: #fff;
  box-shadow: 0 0 6px 0 #EBEDF0;
  z-index: 100;
  &-left {
    display: flex;
    align-items: center;
    .logo {
      margin-left: 16px;
    }
    .title {
      font-weight: 500;
      font-size: 16px;
      color: #000814;
      line-height: 24px;
      margin-left: 40px;
    }
  }
  &-right {
    display: flex;
    align-items: center;
    margin-right: 18px;
    .avatar {
      width: 28px;
      height: 28px;
      background-color: rgba(25, 95, 254, .08);
      border-radius: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 14px;
      color: #195FFE;
      margin-right: 8px;
    }
    .username {
      color: #6E6E7A;
      font-size: 14px;
      margin-right: 8px;
    }
    
  }
}
.logout-popover {
  .arco-popover-content {
    .arco-btn-secondary {
      background-color: #EDF3FF;
      color: #195FFE;
    }
  }
}
</style>