<template>
    <div class='home'>
        <menu-list v-if='showMenu' :modelNum.sync='modelNum' @handlerouterName='handlerouterName'></menu-list>
        <router-view />
    </div>
</template>

<script>
import menuList from '@/components/menuList.vue'

export default {
    props: [],
    data() {
        return {
            modelNum: 0,
            // shebeisheshiShow: false,
            routerName: 'aa',
            imgSrcNum: 1,
            tanchuanShow: false,
            showMenu: true //是否显隐menuList
        }
    },
    computed: {},
    created() {},
    mounted() {
        //   路由为home下的legendLibrary(图例)时,刷新时执行 handleRoute 路由处理函数
        this.handleRoute(this.$route)
    },
    watch: {
        // tanchuanShow(newVal) {
        //   console.log(newVal)
        // }
        $route: 'handleRoute'
    },
    methods: {
        handlerouterName(val) {
            console.log(val)
            this.routerName = val
            if (val == 'de') {
                this.modelNum = 3
            } else if (val == 'floorFunc') {
                this.modelNum = 2
            }
        },
        /**
         * @name handleRoute
         * @param newRoute 当前路由
         * @description 路由处理函数, 当前路由为home下的legendLibrary(图例)时,隐藏 menuList组件
         */
        handleRoute(newRoute) {
            let path = ''
            newRoute.path && (path = newRoute.path)
            if (!path) {
                return true
            }
            let lastPath = path.split('home/')[1]
            if (lastPath === 'legendLibrary') {
                this.showMenu = false
            } else {
                this.showMenu = true
            }
        }
    },

    components: {
        menuList
    }
}
</script>

<style lang="less">
.home {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    canvas:focus {
        outline: none;
    }
}
</style>
