<template>
  <syMoreOperate
    teleport
    :list="operateList"
    :margin-left="-50"
    @click-item="handleClickItem"
  >
    <div
      class="avatar flex-shrink-0 flex justify-center items-center text-white cursor-pointer"
    >
      {{
        (globalState.userInfos.user &&
          globalState.userInfos.user.slice(0, 1)) ||
        "&nbsp"
      }}
    </div>
  </syMoreOperate>
</template>
<script lang="ts" setup>
import { syMoreOperate } from "cqk-sy-ui";

import { globalState } from "@/store/state";
import { router } from "@/router";

const operateList = [
  {
    name: "我的个人主页",
    value: Symbol(),
    click() {
      router.push("/userCenter");
    },
  },
  {
    name: "存证溯源官网",
    value: Symbol(),
    click() {
      router.push("/");
    },
    insertLineAfter: true,
  },
  {
    name: "切换企业版",
    value: Symbol(),
    click() {
      location.href = "https://slc.8n.cn/";
    },
  },
  {
    name: "退出登录",
    value: Symbol(),
    click() {
      sessionStorage.removeItem("user");
      router.push("/");
    },
  },
];

const handleClickItem = (v: any) => {
  operateList.find((i) => i.value === v)?.click();
};

globalState;
</script>

<style lang="scss" scoped>
.avatar {
  width: 35px;
  height: 35px;
  background: var(--sy-blue);
  border-radius: 100%;
}
</style>
