<template>
    <el-container class="hc-layout-box">
        <el-header class="hc-layout-header">
            <div class="header-content-bar">
                <hc-upload-bar />
                <HcRefresh />
                <UserInfoBar @load="userInfoLoad" />
            </div>
        </el-header>
        <el-container class="hc-layout-container">
            <el-aside class="hc-layout-aside" width="200px">
                <MenuBar :cur="menuBarKey" :datas="menuBarData" @change="menuBarChange" />
            </el-aside>
            <el-main class="hc-layout-main">
                <div id="hc-main-box" class="hc-main-page">
                    <hc-body>
                        <router-view />
                    </hc-body>
                </div>
            </el-main>
        </el-container>
    </el-container>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import { useAppStore } from '~src/store'
import { useRouter } from 'vue-router'
import { initButtons } from '~store/app'

//初始组合式
const router = useRouter()
const store = useAppStore()

//子组件
import MenuBar from './modules/MenuBar.vue'
import HcRefresh from './modules/Refresh.vue'
import UserInfoBar from './modules/UserInfoBar.vue'

//菜单数据
const menuBarKey = ref('')
const menuBarData = ref(store.getMenus)

//渲染完成
onMounted(() => {
    initButtons()
})

//菜单被点击
const menuBarChange = ({ code }) => {
    menuBarKey.value = code
    router.push({ name: code })
}


//用户信息
const userInfoLoad = ({ user_id }) => {
    console.log('用户信息', user_id)
}
</script>

<style lang="scss">
@import "./index.scss";
</style>
