<template>
  <div class="tool-bar-ri">
    <div class="header-icon">
      <AssemblySize id="assemblySize" />
      <Language id="language" />
      <SearchMenu id="searchMenu" />
      <ThemeSetting id="themeSetting" />
      <NotificationBell id="notificationBell" />
      <!-- <Message id="message" /> -->
      <Fullscreen id="fullscreen" />
    </div>
    <span class="username">{{ userInfo.name != null ? userInfo.name : userInfo.nickName }}</span>
    <Avatar />
  </div>
</template>

<script setup lang="ts">
import { computed } from "vue";
import { useUserStore } from "@/stores/modules/user";
import AssemblySize from "./components/AssemblySize.vue";
import Language from "./components/Language.vue";
import SearchMenu from "./components/SearchMenu.vue";
import ThemeSetting from "./components/ThemeSetting.vue";
import NotificationBell from "./components/NotificationBell.vue";
import Message from "./components/Message.vue";
import Fullscreen from "./components/Fullscreen.vue";
import Avatar from "./components/Avatar.vue";
import { localGet } from "@/utils/index";

const userStore = useUserStore();
// 使用 computed 来获取响应式的用户信息，优先使用 store 中的数据，否则从本地存储获取
const userInfo = computed(() => {
  return userStore.userInfo && Object.keys(userStore.userInfo).length > 0
    ? userStore.userInfo
    : localGet("geeker-user")?.userInfo || {};
});
</script>

<style scoped lang="scss">
.tool-bar-ri {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 25px;
  .header-icon {
    display: flex;
    align-items: center;
    & > * {
      margin-left: 21px;
      color: var(--el-header-text-color);
    }
  }
  .username {
    margin: 0 20px;
    font-size: 15px;
    color: var(--el-header-text-color);
  }
}
</style>
