| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <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><img height="60px" src="../images/logo.png" alt=""> <span>
- <!-- <el-divider direction="vertical"></el-divider> -->
- {{now}}</span></h1>
- <!-- <img class="logo" src="../images/logo.png" alt=""> -->
- <div class="settings">
- <span>
- <i class="el-icon-s-custom"></i>
- {{info.name}}
- </span>
- <span class="logout" @click="logout"><i class="el-icon-switch-button"></i> 退出登录</span>
- </div>
- </el-header>
- <el-container class="main">
- <!-- 左侧菜单 -->
- <el-aside class="left-aside" width="210px">
- <el-menu background-color='#151932' text-color='#ffffff' :unique-opened='true' :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-show="permission(item.name)" 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-show="permission(item.name)" 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 class="child" 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:{},
- menu:[],
- now:(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString()
- };
- },
- methods: {
- getDate(){
- this.now=(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString()
- },
- logout(){
- localStorage.setItem('token','')
- this.$api.logout().then(res=>{
- this.$router.push({path:'/login'})
- })
- },
- permission(name){
- let permissions=this.info.permissions||[];
- let list=[];
- for(let i=0;i<permissions.length;i++){
- list.push(permissions[i].name)
- }
- if(list.indexOf(name)<0){
- return false;
- }else{
- return true;
- }
- },
- getData(){
- this.$api.getInfo().then(res=>{
- this.info=res.data.data
- })
- }
- },
- created(){
- // console.log(this.$route)
- this.getData()
- var that=this;
- setInterval(function(){
- that.getDate();
- },1000)
- }
- };
- </script>
|