Whalebird-desktop-client-ma.../src/renderer/components/GlobalHeader.vue

79 lines
1.6 KiB
Vue
Raw Normal View History

2018-03-08 11:53:14 +01:00
<template>
<div id="global_header">
<el-menu
:default-active="defaultActive"
class="el-menu-vertical instance-menu"
2018-03-08 11:53:14 +01:00
@open="instanceSelected"
@close="instanceClosed"
:collapse="isCollapse"
background-color="#4a5664"
2018-03-08 11:53:14 +01:00
text-color="#909399"
active-text-color="#ffffff">
<el-menu-item :index="index.toString()" v-for="(instance, index) in instances" v-bind:key="instance.id">
2018-03-08 11:53:14 +01:00
<i class="el-icon-menu"></i>
<span slot="title">{{ instance.baseURL }}</span>
2018-03-08 11:53:14 +01:00
</el-menu-item>
</el-menu>
<div class="space">
2018-03-08 11:53:14 +01:00
<router-view></router-view>
</div>
</div>
</template>
<script>
2018-03-08 15:08:33 +01:00
import { mapState } from 'vuex'
2018-03-08 11:53:14 +01:00
export default {
name: 'global-header',
data () {
return {
isCollapse: true,
defaultActive: '0'
2018-03-08 11:53:14 +01:00
}
},
2018-03-08 15:08:33 +01:00
computed: {
...mapState({
instances: state => state.GlobalHeader.instances
})
},
2018-03-08 11:53:14 +01:00
created () {
2018-03-08 15:08:33 +01:00
this.$store.dispatch('GlobalHeader/listInstances')
.then((instances) => {
return this.$router.push({ path: `/${instances[0].id}/home` })
})
2018-03-08 15:08:33 +01:00
.catch(() => {
return this.$router.push({ path: '/login' })
2018-03-08 15:08:33 +01:00
})
2018-03-08 11:53:14 +01:00
},
methods: {
instanceSelected (key, keyPath) {
console.log(key, keyPath)
},
instanceClosed (key, keyPath) {
console.log(key, keyPath)
}
}
}
</script>
<style lang="scss">
html, body, #app, #global_header {
height: 100%;
margin: 0;
}
#global_header {
.instance-menu {
2018-03-08 11:53:14 +01:00
height: 100%;
position: fixed;
top: 0;
left: 0;
width: 65px;
}
.space {
2018-03-08 11:53:14 +01:00
margin-left: 65px;
}
}
</style>