navbar.vue 5.33 KB
<template>
  <div class="navbar">
    <div class="left-side">
      <a-space>
        <img alt="logo" src="//p3-armor.byteimg.com/tos-cn-i-49unhts6dw/dfdba5317c0c20ce20e64fac803d52bc.svg~tplv-49unhts6dw-image.image" />
        <a-typography-title :heading="5" :style="{ margin: 0, fontSize: '18px' }"> 泡泡留声</a-typography-title>
      </a-space>
    </div>
    <ul class="right-side">
      <!--      <li>-->
      <!--        <toggle-theme-button />-->
      <!--      </li>-->
      <!--      <li>-->
      <!--        <a-tooltip :content="$t('settings.navbar.alerts')">-->
      <!--          <div class="message-box-trigger">-->
      <!--            <a-badge :count="9" dot>-->
      <!--              <a-button-->
      <!--                :shape="'circle'"-->
      <!--                class="nav-btn"-->
      <!--                type="outline"-->
      <!--                @click="setPopoverVisible"-->
      <!--              >-->
      <!--                <icon-notification />-->
      <!--              </a-button>-->
      <!--            </a-badge>-->
      <!--          </div>-->
      <!--        </a-tooltip>-->
      <!--        <a-popover-->
      <!--          :arrow-style="{ display: 'none' }"-->
      <!--          :content-style="{ padding: 0, minWidth: '400px' }"-->
      <!--          content-class="message-popover"-->
      <!--          trigger="click"-->
      <!--        >-->
      <!--          <div ref="refBtn" class="ref-btn"></div>-->
      <!--          <template #content>-->
      <!--            <message-box />-->
      <!--          </template>-->
      <!--        </a-popover>-->
      <!--      </li>-->
      <li>
        <a-dropdown trigger="hover">
          <a-space align="center">
            <a-avatar v-if="avatar" :size="32" :image-url="avatar" />
            <div :style="{ color: theme === 'dark' ? 'white' : 'black', lineHeight: '32px' }">
              <span>{{ name }}</span>
              <icon-down />
            </div>
          </a-space>
          <template #content>
            <!--            <a-doption>-->
            <!--              <a-space @click="switchRoles">-->
            <!--                <icon-tag />-->
            <!--                <span>-->
            <!--                  {{ $t('messageBox.switchRoles') }}-->
            <!--                </span>-->
            <!--              </a-space>-->
            <!--            </a-doption>-->
            <!--            <a-doption>-->
            <!--              <a-space @click="handleChangePwd">-->
            <!--                <icon-lock />-->
            <!--                <span>修改密码</span>-->
            <!--              </a-space>-->
            <!--            </a-doption>-->
            <a-doption>
              <a-space @click="handleLogout">
                <icon-export />
                <span> 退出登录 </span>
              </a-space>
            </a-doption>
          </template>
        </a-dropdown>
      </li>
    </ul>
  </div>
</template>

<script lang="ts" setup>
  import { computed } from 'vue';
  import { useAppStore, useAuthorizedStore } from '@/store';
  // import useUser from '@/hooks/user';
  // import ToggleThemeButton from '@/layout/components/toggle-theme-button.vue';
  import { IconDown, IconExport } from '@arco-design/web-vue/es/icon';

  const appStore = useAppStore();
  const authorized = useAuthorizedStore();

  const avatar = computed(() => {
    return authorized.avatar;
  });

  const name = computed(() => {
    return authorized.nick_name;
  });

  const { theme } = appStore;

  // const theme = computed(() => {
  //   return appStore.theme;
  // });

  // const setVisible = () => {
  //   appStore.updateSettings({ globalSettings: true });
  // };
  // const refBtn = ref();
  // const triggerBtn = ref();
  // const setPopoverVisible = () => {
  //   const event = new MouseEvent('click', {
  //     view: window,
  //     bubbles: true,
  //     cancelable: true,
  //   });
  //   refBtn.value.dispatchEvent(event);
  // };
  const handleLogout = () => authorized.logout();

  // const handleChangePwd = () => useUser().resetPwd();
  // const setDropDownVisible = () => {
  //   const event = new MouseEvent('click', {
  //     view: window,
  //     bubbles: true,
  //     cancelable: true,
  //   });
  //   triggerBtn.value.dispatchEvent(event);
  // };
</script>

<style lang="less" scoped>
  .navbar {
    display: flex;
    justify-content: space-between;
    height: 100%;
    background-color: var(--color-bg-2);
    border-bottom: 1px solid var(--color-border);
  }

  .left-side {
    display: flex;
    align-items: center;
    padding-left: 20px;
  }

  .right-side {
    display: flex;
    padding-right: 10px;
    list-style: none;

    :deep(.locale-select) {
      border-radius: 20px;
    }

    li {
      display: flex;
      align-items: center;
      padding: 0 10px;
    }

    a {
      color: var(--color-text-1);
      text-decoration: none;
    }

    .nav-btn {
      border-color: rgb(var(--gray-2));
      color: rgb(var(--gray-8));
      font-size: 16px;
    }

    .trigger-btn,
    .ref-btn {
      position: absolute;
      bottom: 14px;
    }

    .trigger-btn {
      margin-left: 14px;
    }
  }
</style>

<style lang="less">
  .message-popover {
    .arco-popover-content {
      margin-top: 0;
    }
  }

  .arco-dropdown-open .arco-icon-down {
    transform: rotate(180deg);
  }
</style>