2018-02-14 14:53:52 +09:00
|
|
|
<template>
|
|
|
|
<div class="mk-ui">
|
2018-02-24 02:46:09 +09:00
|
|
|
<x-header>
|
|
|
|
<template slot="func"><slot name="func"></slot></template>
|
2018-02-15 17:50:19 +09:00
|
|
|
<slot name="header"></slot>
|
2018-02-22 02:37:04 +09:00
|
|
|
</x-header>
|
|
|
|
<x-nav :is-open="isDrawerOpening"/>
|
2018-02-14 14:53:52 +09:00
|
|
|
<div class="content">
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2018-05-27 13:49:09 +09:00
|
|
|
<mk-stream-indicator v-if="$store.getters.isSignedIn"/>
|
2018-02-14 14:53:52 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-02-22 03:11:24 +09:00
|
|
|
import MkNotify from './notify.vue';
|
2018-02-22 02:37:04 +09:00
|
|
|
import XHeader from './ui.header.vue';
|
|
|
|
import XNav from './ui.nav.vue';
|
|
|
|
|
2018-02-14 14:53:52 +09:00
|
|
|
export default Vue.extend({
|
2018-02-22 02:37:04 +09:00
|
|
|
components: {
|
|
|
|
XHeader,
|
|
|
|
XNav
|
|
|
|
},
|
2018-10-07 11:06:17 +09:00
|
|
|
|
2018-02-24 02:46:09 +09:00
|
|
|
props: ['title'],
|
2018-10-07 11:06:17 +09:00
|
|
|
|
2018-02-14 14:53:52 +09:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isDrawerOpening: false,
|
2018-10-07 11:06:17 +09:00
|
|
|
connection: null
|
2018-02-14 14:53:52 +09:00
|
|
|
};
|
|
|
|
},
|
2018-10-07 11:06:17 +09:00
|
|
|
|
2018-08-30 22:10:29 +09:00
|
|
|
watch: {
|
|
|
|
'$store.state.uiHeaderHeight'() {
|
|
|
|
this.$el.style.paddingTop = this.$store.state.uiHeaderHeight + 'px';
|
|
|
|
}
|
|
|
|
},
|
2018-10-07 11:06:17 +09:00
|
|
|
|
2018-02-14 14:53:52 +09:00
|
|
|
mounted() {
|
2018-08-30 22:10:29 +09:00
|
|
|
this.$el.style.paddingTop = this.$store.state.uiHeaderHeight + 'px';
|
|
|
|
|
2018-05-27 13:49:09 +09:00
|
|
|
if (this.$store.getters.isSignedIn) {
|
2018-11-09 08:13:34 +09:00
|
|
|
this.connection = this.$root.stream.useSharedConnection('main');
|
2018-02-14 14:53:52 +09:00
|
|
|
|
|
|
|
this.connection.on('notification', this.onNotification);
|
|
|
|
}
|
|
|
|
},
|
2018-10-07 11:06:17 +09:00
|
|
|
|
2018-02-14 14:53:52 +09:00
|
|
|
beforeDestroy() {
|
2018-05-27 13:49:09 +09:00
|
|
|
if (this.$store.getters.isSignedIn) {
|
2018-10-07 11:06:17 +09:00
|
|
|
this.connection.dispose();
|
2018-02-14 14:53:52 +09:00
|
|
|
}
|
|
|
|
},
|
2018-10-07 11:06:17 +09:00
|
|
|
|
2018-02-14 14:53:52 +09:00
|
|
|
methods: {
|
|
|
|
onNotification(notification) {
|
|
|
|
// TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない
|
2018-11-09 08:13:34 +09:00
|
|
|
this.$root.stream.send('readNotification', {
|
2018-02-14 14:53:52 +09:00
|
|
|
id: notification.id
|
|
|
|
});
|
|
|
|
|
2018-11-09 08:13:34 +09:00
|
|
|
this.$root.new(MkNotify, {
|
2018-02-22 23:53:07 +09:00
|
|
|
notification
|
|
|
|
});
|
2018-02-14 14:53:52 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.mk-ui
|
2018-02-23 04:01:22 +09:00
|
|
|
display flex
|
|
|
|
flex 1
|
2018-02-23 04:07:22 +09:00
|
|
|
flex-direction column
|
2018-02-14 14:53:52 +09:00
|
|
|
padding-top 48px
|
2018-02-23 04:01:22 +09:00
|
|
|
|
|
|
|
> .content
|
|
|
|
display flex
|
|
|
|
flex 1
|
|
|
|
flex-direction column
|
2018-02-14 14:53:52 +09:00
|
|
|
</style>
|