rudeshark.net/src/client/app/mobile/views/components/ui.vue

85 lines
1.6 KiB
Vue
Raw Normal View History

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