<template>
  <div class="box" :class="{mini: isMini}">
    <div class="list d-flex flex-column">
      <div style="flex: 1; height: 0; overflow: auto;">
        <v-list color="rgba(0,0,0,0)" subheader>
          <slot></slot>
          <side-list :items="list" :mini-menu="isMini" />
        </v-list>
      </div>
      <!-- <div class="list-bottom white">
        <v-divider></v-divider>
        <div class="pa-3">
          <div class="d-flex mb-1">
            <div class="list-bottom-label mr-3">今日访问</div>
            <div>{{ dayTotal }}</div>
          </div>
          <div class="d-flex">
            <div class="list-bottom-label mr-3">总访问量</div>
            <div>{{ total }}</div>
          </div>
        </div>
      </div> -->
    </div>
    <!-- <div class="tools"> -->
      <!-- 判断是否有权限 -->
      <!-- <v-btn depressed color="blue-grey" class="white--text">
        <v-icon
          left
          dark
        >
        mdi-cog
        </v-icon>
        菜单设置
      </v-btn> -->
    <!-- </div> -->
  </div>
</template>

<script>
import SideList from '@/components/Side/sideList.vue'
import { mapGetters } from 'vuex'
// import { getBurialPointStatistics } from '@/api/system'
export default {
  name: 'side-index',
  components: { SideList },
  props: {
    isMini: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      active: false,
      dayTotal: 0,
      total: 0
    }
  },
  computed: {
    ...mapGetters(['roles']),
    list () {
      return this.getList(this.roles)
    }
  },
  // created () {
  //   this.handleGetBurialPointStatistics()
  // },
  methods: {
    getList (arr, obj = []) {
      arr.sort((a, b) => a - b).forEach(element => {
        if (element.hidden) return
        const data = {}
        data.title = element.meta.title
        data.target = element.meta.target
        data.enName = element.enName
        data.name = element.name
        data.path = element.path
        data.icon = element.icon
        data.active = false
        data.children = []
        if (element?.children) {
          this.getList(element.children, data.children)
        }
        obj.push(data)
      })
      return obj
    }
    // async handleGetBurialPointStatistics () {
    //   try {
    //     const { data } = await getBurialPointStatistics()
    //     this.dayTotal = data.dayTotal ?? 0
    //     this.total = data.total ?? 0
    //   } catch (error) {
    //     this.$snackbar.error(error)
    //   }
    // }
  }
}
</script>

<style lang="scss" scoped>
.box {
  width: 230px;
  &.mini {
    width: 60px;
  }
  .card {
    // background: var(--v-info-lighten2);
    display: flex;
    flex-direction: column;
  }
  .list {
    height: 100%;
    &-bottom {
      // position: sticky;
      // bottom: 0;
    }
  }
  .tools {
    width: 100%;
    height: 60px;
    // position: absolute;
    display: flex;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
  }
}
</style>
