<style lang="scss">
@import '../style/home.scss';
.head{
	width:30px;
	height:30px;
	border-radius:50%;
	float:left;
	margin:10px;
}
</style>

<template>
	<el-container>
		<el-header class="header">
			<h1>巴中逸沣安全培训</h1>
			<!-- <img class="logo" src="../images/logo.png" alt=""> -->
			<div class="settings">
				<span>
					<!-- <img width="16" src="../images/msg.png" alt="">  -->
					{{info.name}}</span>
        <span @click="logout">退出登录</span>
			</div>
		</el-header>
		<el-container class="main">
			<!-- 左侧菜单 -->
			<el-aside class="left-aside" width="210px">
           <el-menu  :default-active="$route.path" router class="left-menue" active-text-color="#ffffff">
            <template v-for="(item, index) in $router.options.routes">
              <el-menu-item v-if='item.show&&item.isLeaf' :index="item.path"  :key='index'>
                <i :class="item.icon"></i>
                <span slot="title">{{item.name}}</span>
              </el-menu-item>
              <el-submenu v-if='item.show&&!item.isLeaf' :index="'index_'+index"  :key='index'>
                <template slot="title">
                  <i :class="item.icon"></i>
                  <span>{{item.name}}</span>
                </template>
                <el-menu-item-group >
                  	<el-menu-item v-for="(child,idx) in item.children" :key="index+'_'+idx" :index="child.path" v-show='!child.hide'>
					  {{child.name}}
					</el-menu-item>
                </el-menu-item-group>
              </el-submenu>
            </template>
          </el-menu>
			</el-aside>
			<!-- 右侧内容 -->
			<el-container>
				<el-main>			
					<transition name="fade" mode="out-in"><router-view :info='info' :community='community'></router-view></transition>
				</el-main>
				<!-- <el-footer>Footer</el-footer> -->
			</el-container>
		</el-container>
	</el-container>
</template>

<script>
export default {
	name: 'home',
	data() {
		return {
			menuList:[],
			path:'',
			info:{},
			community_list:[],
			community:{}
		};
	},
	methods: {
		logout(){
			this.$api.logout().then(res=>{
				this.$router.push({path:'/login'})
			})
		},
		getData(){
			this.$api.getInfo().then(res=>{
				this.info=res.data.data
			})
		}
	},
	$route(to){
    },
	created(){
		this.getData()
		// if(this.$route.path.indexOf('add')>=0){
		// 	this.path=this.$route.path.split('/add')[0]
		// }else if(this.$route.path.indexOf('edit')>=0){
		// 	this.path=this.$route.path.split('/edit')[0]
		// }else if(this.$route.path.indexOf('detail')>=0){
		// 	this.path=this.$route.path.split('/detail')[0]
		// }else{
		// 	this.path=this.$route.path
		// }
	}
};
</script>
