1. fix side menu height
2. add logout button
This commit is contained in:
Jay 2018-08-23 20:44:09 +08:00
parent 18f14d66a4
commit cb541abacb
3 changed files with 30 additions and 4 deletions

View File

@ -1,9 +1,11 @@
<template> <template>
<div class='f-container' v-if="channel !== null"> <div class='f-container' v-if="channel !== null">
<div class='f-menu'> <div class='f-menu'>
<sui-segment style='margin: 0 auto; width: 80%;'> <sui-container textAlign='center'>
<sui-segment style="width: 80%; margin: 0 auto;">
<ChannelMenu /> <ChannelMenu />
</sui-segment> </sui-segment>
</sui-container>
</div> </div>
<div class='f-full'> <div class='f-full'>
<sui-container> <sui-container>

View File

@ -8,18 +8,29 @@
</sui-menu-menu> </sui-menu-menu>
<sui-menu-menu position='right'> <sui-menu-menu position='right'>
<sui-menu-item>User: {{userInfo.name}}</sui-menu-item> <sui-menu-item>User: {{userInfo.name}}</sui-menu-item>
<sui-menu-item @click.native="doLogout">Logout</sui-menu-item>
</sui-menu-menu> </sui-menu-menu>
</sui-container> </sui-container>
</sui-menu> </sui-menu>
</template> </template>
<script> <script>
import {mapGetters} from 'vuex' import {mapGetters, mapActions} from 'vuex'
export default { export default {
name: 'TopMenu', name: 'TopMenu',
data () { data () {
return {} return {}
}, },
methods: {
...mapActions(['sendLogout']),
doLogout: function () {
this.sendLogout({
cb: () => {
this.$router.replace('/')
}
})
}
},
computed: { computed: {
...mapGetters(['userInfo']), ...mapGetters(['userInfo']),
activeItem: function () { activeItem: function () {

View File

@ -70,6 +70,19 @@ export default {
} }
commit('toggleLoading', false) commit('toggleLoading', false)
}, },
async sendLogout ({commit}, {cb}) {
commit('toggleLoading', true)
try {
await client({
method: 'post',
url: '/api/logout'
})
} catch (err) {
}
if (typeof cb === 'function') cb()
commit('toggleLoading', false)
},
async getChannelList ({commit}, cb = null) { async getChannelList ({commit}, cb = null) {
commit('toggleLoading', true) commit('toggleLoading', true)
try { try {