<template>
  <div class="home">
    <a-layout class="home-page">
      <a-layout-header class="header">
        <div class="header-right">
          <bell-outlined />
        </div>
        <div class="header-right">
          <RadarChartOutlined /><span>{{ info.name }}</span>
        </div>
        <div class="header-right">
          <DashOutlined />
        </div>
      </a-layout-header>
      <a-layout>
        <a-layout-sider width="200" style="background: #fff">
          <a-menu
            v-model:selectedKeys="selectedKeys"
            theme="dark"
            mode="inline"
          >
            <a-menu-item
              v-for="item in router.options.routes"
              :key="item"
              @click="goNewPage(item)"
            >
              <div style="display: flex; align-items: center" >
                <AlipaySquareFilled
                  v-if="item.id === 1"
                  style="font-size: 25px"
                />
                <DatabaseFilled v-else style="font-size: 25px" />
                <span class="nav-text" >{{ item.name }}</span>
              </div>
            </a-menu-item>
          </a-menu>
        </a-layout-sider>
        <a-layout style="padding: 0 24px 24px;height: 100%;">
          <a-layout-content
            :style="{
              background: '#fff',
              padding: '24px',
              margin: 0,
            }"
          >
            <router-view></router-view>
          </a-layout-content>
        </a-layout>
      </a-layout>
    </a-layout>
  </div>
</template>
<script lang="ts" setup>
import { ref, reactive, defineExpose, onMounted } from "vue";
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import {
  BellOutlined,
  RadarChartOutlined,
  DashOutlined,
  AlipaySquareFilled,
  DatabaseFilled,
} from "@ant-design/icons-vue";
import { getRouters } from "@/api/index";
import { onSetRouter} from  "@/utils/userInfo"
interface FormUser {
  name: String;
  password: String;
}
const router = useRouter();
const store = useStore();
const selectedKeys = ref<string[]>(["1"])
const info = reactive<FormUser>(store.getters.getUserInfo);
const goNewPage = (e: any) => {
  const { path } = e;
  router.push({
    path,
    query:{
    }
  });
};
defineExpose({
  selectedKeys,
  openKeys: ref<string[]>(["sub1"]),
  goNewPage,
  info,
  router
});
</script>
<style>
#components-layout-demo-top-side-2 .logo {
  float: left;
  width: 120px;
  height: 31px;
  margin: 16px 24px 16px 0;
  background: rgba(255, 255, 255, 0.3);
}

.ant-row-rtl #components-layout-demo-top-side-2 .logo {
  float: right;
  margin: 16px 0 16px 24px;
}

.site-layout-background {
  background: #fff;
}

.ant-menu-submenu-arrow {
  display: none;
}
</style>
<style scoped>
.custom-icons-list :deep(.anticon) {
  margin-right: 6px;
}
</style>
<style lang="less">
.home {
  width: 100%;
  height: 100%;
  .ant-layout {
    height: 871px;
    overflow-y: hidden;
    padding: 0px !important;
    background-color: white;
  }
  .ant-layout-sider-children {
    background: rgb(235, 235, 235);
  }
  .ant-layout-has-sider {
    overflow: hidden;
  }

  .home-page {
    height: 100%;
    overflow: hidden;

    .header {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      background-color: @primary-color;

      .header-right {
        margin-right: 40px;
      }
    }
  }
}
</style>
