2018-02-14 06:53:52 +01:00
|
|
|
<template>
|
|
|
|
<div class="mk-ui">
|
2018-02-15 09:50:19 +01:00
|
|
|
<mk-ui-header :func="func" :func-icon="funcIcon">
|
|
|
|
<slot name="header"></slot>
|
|
|
|
</mk-ui-header>
|
2018-02-14 06:53:52 +01:00
|
|
|
<mk-ui-nav :is-open="isDrawerOpening"/>
|
|
|
|
<div class="content">
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2018-02-18 04:35:18 +01:00
|
|
|
<mk-stream-indicator v-if="os.isSignedIn"/>
|
2018-02-14 06:53:52 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
export default Vue.extend({
|
2018-02-15 09:50:19 +01:00
|
|
|
props: ['title', 'func', 'funcIcon'],
|
2018-02-14 06:53:52 +01:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isDrawerOpening: false,
|
|
|
|
connection: null,
|
|
|
|
connectionId: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-02-18 04:35:18 +01:00
|
|
|
if ((this as any).os.isSignedIn) {
|
|
|
|
this.connection = (this as any).os.stream.getConnection();
|
|
|
|
this.connectionId = (this as any).os.stream.use();
|
2018-02-14 06:53:52 +01:00
|
|
|
|
|
|
|
this.connection.on('notification', this.onNotification);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-02-18 04:35:18 +01:00
|
|
|
if ((this as any).os.isSignedIn) {
|
2018-02-14 06:53:52 +01:00
|
|
|
this.connection.off('notification', this.onNotification);
|
2018-02-18 04:35:18 +01:00
|
|
|
(this as any).os.stream.dispose(this.connectionId);
|
2018-02-14 06:53:52 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onNotification(notification) {
|
|
|
|
// TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない
|
|
|
|
this.connection.send({
|
|
|
|
type: 'read_notification',
|
|
|
|
id: notification.id
|
|
|
|
});
|
|
|
|
|
|
|
|
document.body.appendChild(new MkNotify({
|
|
|
|
propsData: {
|
|
|
|
notification
|
|
|
|
}
|
|
|
|
}).$mount().$el);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.mk-ui
|
|
|
|
padding-top 48px
|
|
|
|
</style>
|