monkeeShark/src/client/app/mobile/views/components/ui.vue

76 lines
1.6 KiB
Vue
Raw Normal View History

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