2018-03-08 11:53:14 +01:00
|
|
|
<template>
|
|
|
|
<div id="global_header">
|
|
|
|
<el-menu
|
|
|
|
:default-active="defaultActive"
|
2018-03-09 07:21:25 +01:00
|
|
|
class="el-menu-vertical instance-menu"
|
2018-03-08 11:53:14 +01:00
|
|
|
@open="instanceSelected"
|
|
|
|
@close="instanceClosed"
|
|
|
|
:collapse="isCollapse"
|
2018-03-09 07:21:25 +01:00
|
|
|
background-color="#4a5664"
|
2018-03-08 11:53:14 +01:00
|
|
|
text-color="#909399"
|
|
|
|
active-text-color="#ffffff">
|
2018-03-08 16:24:18 +01:00
|
|
|
<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>
|
2018-03-08 16:24:18 +01:00
|
|
|
<span slot="title">{{ instance.baseURL }}</span>
|
2018-03-08 11:53:14 +01:00
|
|
|
</el-menu-item>
|
|
|
|
</el-menu>
|
2018-03-09 07:21:25 +01:00
|
|
|
<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,
|
2018-03-08 16:24:18 +01:00
|
|
|
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')
|
2018-03-08 16:24:18 +01:00
|
|
|
.then((instances) => {
|
2018-03-09 07:21:25 +01:00
|
|
|
return this.$router.push({ path: `/${instances[0].id}/home` })
|
2018-03-08 16:24:18 +01:00
|
|
|
})
|
2018-03-08 15:08:33 +01:00
|
|
|
.catch(() => {
|
2018-03-08 16:24:18 +01:00
|
|
|
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 {
|
2018-03-09 07:21:25 +01:00
|
|
|
.instance-menu {
|
2018-03-08 11:53:14 +01:00
|
|
|
height: 100%;
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 65px;
|
|
|
|
}
|
|
|
|
|
2018-03-09 07:21:25 +01:00
|
|
|
.space {
|
2018-03-08 11:53:14 +01:00
|
|
|
margin-left: 65px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|