Last active
June 26, 2017 12:40
-
-
Save tiagocardosos/03eb567feb88f1b23d46df04c7c3453e to your computer and use it in GitHub Desktop.
Utilizar multiplos templates em 1 component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<spinner global text="Aguarde..."></spinner> | |
<div id="wrapper" v-if="isAuth" class="fixed-nav skin-1" :class="{ 'mini-navbar': isOpen }"> | |
<preloader-component></preloader-component> | |
<nav-component></nav-component> | |
<div id="page-wrapper" class="gray-bg"> | |
<nav-top-component @toogle="onToogleMenu"></nav-top-component> | |
<header-title-component></header-title-component> | |
<div class="wrapper wrapper-content animated fadeInRight"> | |
<keep-alive> | |
<transition> | |
<router-view></router-view> | |
</transition> | |
</keep-alive> | |
</div> | |
<footer-component></footer-component> | |
</div> | |
</div> | |
<div v-else> | |
<component :is="view"></component> | |
</div> | |
</div> | |
</template> | |
<script> | |
import PreloaderComponent from './components/Preloader.vue' | |
import NavComponent from './components/Nav.vue' | |
import NavTopComponent from './components/NavTop.vue' | |
import FooterComponent from './components/Footer.vue' | |
import HeaderTitleComponent from './components/HeaderTitle.vue' | |
import Login from './components/auth/Login.vue' | |
import Cadastrar from './components/auth/CadastrarPF.vue' | |
import spinner from './components/Spinner.vue' | |
import AceitarConvite from './components/usuario/AceiteConvite.vue' | |
import bus from './utils/bus' | |
import { mapActions } from 'vuex' | |
export default { | |
name: 'app', | |
components: { | |
NavComponent, | |
NavTopComponent, | |
FooterComponent, | |
HeaderTitleComponent, | |
PreloaderComponent, | |
Login, | |
Cadastrar, | |
spinner, | |
AceitarConvite | |
}, | |
data () { | |
return { | |
spinner: false, | |
isOpen: true, | |
} | |
}, | |
computed: { | |
view(){ | |
if (this.$route.name == 'auth.cadastrar') { | |
return Cadastrar | |
} else if(this.$route.name == 'auth.ConviteAceito') { | |
return AceitarConvite | |
} | |
return Login | |
}, | |
isAuth(){ | |
return this.$store.state.auth.check || false | |
}, | |
}, | |
mounted(){ | |
bus.$on('loadNotificacoes', this.notificacoes) | |
}, | |
methods: { | |
...mapActions(['usuarioNotificacoes']), | |
onToogleMenu(){ | |
this.isOpen = !this.isOpen | |
}, | |
notificacoes(){ | |
this.usuarioNotificacoes() | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment