mizzkey/src/client/root.vue

73 lines
1.8 KiB
Vue
Raw Normal View History

2020-07-21 17:38:17 +02:00
<template>
2020-07-24 04:59:26 +02:00
<DeckUI v-if="deckmode"/>
<DefaultUI v-else/>
2020-09-05 04:14:42 +02:00
2020-09-05 12:38:57 +02:00
<XPostFormDialog v-if="$store.state.postForm" v-bind="$store.state.postForm"/>
2020-09-05 09:53:27 +02:00
2020-09-05 17:20:06 +02:00
<XMenu v-if="menu" v-bind="menu" :key="menu.id"/>
2020-09-05 09:53:27 +02:00
<XDialog v-if="dialog" v-bind="dialog" :key="dialog.id"/>
2020-07-21 17:38:17 +02:00
</template>
<script lang="ts">
2020-09-05 04:14:42 +02:00
import { defineComponent, defineAsyncComponent } from 'vue';
2020-07-21 17:38:17 +02:00
import DefaultUI from './default.vue';
import DeckUI from './deck.vue';
2020-07-23 16:39:15 +02:00
import { instanceName, deckmode } from './config';
2020-07-21 17:38:17 +02:00
2020-07-23 20:15:32 +02:00
export default defineComponent({
2020-07-21 17:38:17 +02:00
components: {
DefaultUI,
DeckUI,
2020-09-05 04:14:42 +02:00
XDialog: defineAsyncComponent(() => import('./components/dialog.vue')),
2020-09-05 17:20:06 +02:00
XMenu: defineAsyncComponent(() => import('./components/menu.vue')),
2020-09-05 12:38:57 +02:00
XPostFormDialog: defineAsyncComponent(() => import('./components/post-form-dialog.vue')),
2020-07-21 17:38:17 +02:00
},
2020-07-23 06:02:46 +02:00
metaInfo: {
title: null,
titleTemplate: title => title ? `${title} | ${(instanceName || 'Misskey')}` : (instanceName || 'Misskey')
},
2020-07-24 04:59:26 +02:00
props: {
2020-07-24 09:30:55 +02:00
// TODO: propで渡すとvueによって無駄なobserveがされるのでどうにかする
2020-07-24 04:59:26 +02:00
stream: {
},
isMobile: {
type: Boolean,
required: false,
default: false,
}
},
2020-07-21 17:38:17 +02:00
data() {
return {
2020-07-24 04:59:26 +02:00
deckmode
2020-07-21 17:38:17 +02:00
};
},
2020-09-05 04:14:42 +02:00
computed: {
dialog() {
if (this.$store.state.dialogs.length === 0) return null;
// what: ダイアログが複数ある場合は、一番最後に追加されたダイアログを表示する
// why: ダイアログが一度に複数表示されるとユーザビリティが悪いため。
return this.$store.state.dialogs[this.$store.state.dialogs.length - 1];
2020-09-05 17:20:06 +02:00
},
menu() {
if (this.$store.state.menus.length === 0) return null;
return this.$store.state.menus[this.$store.state.menus.length - 1];
2020-09-05 04:14:42 +02:00
}
},
2020-07-21 17:38:17 +02:00
methods: {
2020-09-05 06:04:59 +02:00
api(endpoint: string, data: Record<string, any> = {}, token?) {
2020-07-24 12:35:19 +02:00
return this.$store.dispatch('api', { endpoint, data, token });
},
2020-07-21 17:38:17 +02:00
}
});
</script>