2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
|
|
|
<div class="mk-home" v-hotkey.global="keymap">
|
2020-02-01 09:12:04 +09:00
|
|
|
<portal to="header" v-if="showTitle">
|
2020-01-30 04:37:25 +09:00
|
|
|
<button @click="choose" class="_button _kjvfvyph_">
|
|
|
|
<i><fa v-if="$store.state.i.hasUnreadAntenna" :icon="faCircle"/></i>
|
|
|
|
<fa v-if="src === 'home'" :icon="faHome"/>
|
|
|
|
<fa v-if="src === 'local'" :icon="faComments"/>
|
|
|
|
<fa v-if="src === 'social'" :icon="faShareAlt"/>
|
|
|
|
<fa v-if="src === 'global'" :icon="faGlobe"/>
|
|
|
|
<fa v-if="src === 'list'" :icon="faListUl"/>
|
|
|
|
<fa v-if="src === 'antenna'" :icon="faSatellite"/>
|
|
|
|
<span style="margin-left: 8px;">{{ src === 'list' ? list.name : src === 'antenna' ? antenna.name : $t('_timelines.' + src) }}</span>
|
|
|
|
<fa :icon="menuOpened ? faAngleUp : faAngleDown" style="margin-left: 8px;"/>
|
|
|
|
</button>
|
|
|
|
</portal>
|
2020-02-09 21:31:17 +09:00
|
|
|
|
2020-02-19 04:08:35 +09:00
|
|
|
<div class="new" v-if="queue > 0" :style="{ width: width + 'px' }"><button class="_buttonPrimary" @click="top()">{{ $t('newNoteRecived') }}</button></div>
|
|
|
|
|
2020-02-09 22:25:32 +09:00
|
|
|
<x-tutorial class="tutorial" v-if="$store.state.settings.tutorial != -1"/>
|
2020-02-09 21:31:17 +09:00
|
|
|
|
2020-02-19 03:16:10 +09:00
|
|
|
<x-post-form class="post-form _panel" fixed v-if="$store.state.device.showFixedPostForm"/>
|
2020-02-19 04:08:35 +09:00
|
|
|
<x-timeline ref="tl" :key="src === 'list' ? `list:${list.id}` : src === 'antenna' ? `antenna:${antenna.id}` : src" :src="src" :list="list" :antenna="antenna" @before="before()" @after="after()" @queue="queueUpdated"/>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2020-02-09 22:25:32 +09:00
|
|
|
import { faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faListUl, faSatellite, faCircle } from '@fortawesome/free-solid-svg-icons';
|
2020-01-30 04:37:25 +09:00
|
|
|
import { faComments } from '@fortawesome/free-regular-svg-icons';
|
|
|
|
import Progress from '../scripts/loading';
|
|
|
|
import XTimeline from '../components/timeline.vue';
|
2020-02-09 22:25:32 +09:00
|
|
|
import XTutorial from './index.home.tutorial.vue';
|
2020-02-19 03:11:09 +09:00
|
|
|
import XPostForm from '../components/post-form.vue';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
metaInfo() {
|
|
|
|
return {
|
|
|
|
title: this.$t('timeline') as string
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
2020-02-09 21:31:17 +09:00
|
|
|
XTimeline,
|
2020-02-09 22:25:32 +09:00
|
|
|
XTutorial,
|
2020-02-19 03:11:09 +09:00
|
|
|
XPostForm,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
|
2020-02-01 09:12:04 +09:00
|
|
|
props: {
|
|
|
|
showTitle: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
src: 'home',
|
|
|
|
list: null,
|
|
|
|
antenna: null,
|
|
|
|
menuOpened: false,
|
2020-02-19 04:08:35 +09:00
|
|
|
queue: 0,
|
|
|
|
width: 0,
|
2020-02-09 22:25:32 +09:00
|
|
|
faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faComments, faListUl, faSatellite, faCircle
|
2020-01-30 04:37:25 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
't': this.focus
|
|
|
|
};
|
2020-02-09 21:31:17 +09:00
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
src() {
|
|
|
|
this.showNav = false;
|
|
|
|
this.saveSrc();
|
|
|
|
},
|
|
|
|
list(x) {
|
|
|
|
this.showNav = false;
|
|
|
|
this.saveSrc();
|
|
|
|
if (x != null) this.antenna = null;
|
|
|
|
},
|
|
|
|
antenna(x) {
|
|
|
|
this.showNav = false;
|
|
|
|
this.saveSrc();
|
|
|
|
if (x != null) this.list = null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-02-10 07:23:43 +09:00
|
|
|
this.src = this.$store.state.deviceUser.tl.src;
|
|
|
|
if (this.src === 'list') {
|
|
|
|
this.list = this.$store.state.deviceUser.tl.arg;
|
|
|
|
} else if (this.src === 'antenna') {
|
|
|
|
this.antenna = this.$store.state.deviceUser.tl.arg;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
before() {
|
|
|
|
Progress.start();
|
|
|
|
},
|
|
|
|
|
|
|
|
after() {
|
|
|
|
Progress.done();
|
|
|
|
},
|
|
|
|
|
2020-02-19 04:08:35 +09:00
|
|
|
queueUpdated(q) {
|
|
|
|
this.width = this.$el.offsetWidth;
|
|
|
|
this.queue = q;
|
|
|
|
},
|
|
|
|
|
|
|
|
top() {
|
|
|
|
window.scroll({ top: 0, behavior: 'instant' });
|
|
|
|
},
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
async choose(ev) {
|
|
|
|
this.menuOpened = true;
|
|
|
|
const [antennas, lists] = await Promise.all([
|
|
|
|
this.$root.api('antennas/list'),
|
|
|
|
this.$root.api('users/lists/list')
|
|
|
|
]);
|
|
|
|
const antennaItems = antennas.map(antenna => ({
|
|
|
|
text: antenna.name,
|
|
|
|
icon: faSatellite,
|
|
|
|
indicate: antenna.hasUnreadNote,
|
|
|
|
action: () => {
|
|
|
|
this.antenna = antenna;
|
|
|
|
this.setSrc('antenna');
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
const listItems = lists.map(list => ({
|
|
|
|
text: list.name,
|
|
|
|
icon: faListUl,
|
|
|
|
action: () => {
|
|
|
|
this.list = list;
|
|
|
|
this.setSrc('list');
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
this.$root.menu({
|
|
|
|
items: [{
|
|
|
|
text: this.$t('_timelines.home'),
|
|
|
|
icon: faHome,
|
|
|
|
action: () => { this.setSrc('home') }
|
|
|
|
}, {
|
|
|
|
text: this.$t('_timelines.local'),
|
|
|
|
icon: faComments,
|
|
|
|
action: () => { this.setSrc('local') }
|
|
|
|
}, {
|
|
|
|
text: this.$t('_timelines.social'),
|
|
|
|
icon: faShareAlt,
|
|
|
|
action: () => { this.setSrc('social') }
|
|
|
|
}, {
|
|
|
|
text: this.$t('_timelines.global'),
|
|
|
|
icon: faGlobe,
|
|
|
|
action: () => { this.setSrc('global') }
|
|
|
|
}, antennaItems.length > 0 ? null : undefined, ...antennaItems, listItems.length > 0 ? null : undefined, ...listItems],
|
|
|
|
fixed: true,
|
|
|
|
noCenter: true,
|
|
|
|
source: ev.currentTarget || ev.target
|
|
|
|
}).then(() => {
|
|
|
|
this.menuOpened = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setSrc(src) {
|
|
|
|
this.src = src;
|
|
|
|
},
|
|
|
|
|
|
|
|
saveSrc() {
|
2020-02-10 07:23:43 +09:00
|
|
|
this.$store.commit('deviceUser/setTl', {
|
2020-01-30 04:37:25 +09:00
|
|
|
src: this.src,
|
|
|
|
arg: this.src == 'list' ? this.list : this.antenna
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
(this.$refs.tl as any).focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-02-09 21:31:17 +09:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.mk-home {
|
2020-02-19 04:08:35 +09:00
|
|
|
> .new {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
display: block;
|
|
|
|
margin: 0 auto;
|
|
|
|
padding: 8px 12px;
|
|
|
|
border-radius: 32px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-09 22:25:32 +09:00
|
|
|
> .tutorial {
|
2020-02-09 21:31:17 +09:00
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
|
|
|
|
2020-02-19 03:16:10 +09:00
|
|
|
> .post-form {
|
|
|
|
position: relative;
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
2020-02-19 03:11:09 +09:00
|
|
|
}
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
._kjvfvyph_ {
|
|
|
|
position: relative;
|
|
|
|
height: 100%;
|
|
|
|
padding: 0 16px;
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
|
|
> i {
|
|
|
|
position: absolute;
|
|
|
|
top: 16px;
|
|
|
|
right: 8px;
|
2020-02-17 07:14:03 +09:00
|
|
|
color: var(--indicator);
|
2020-01-30 04:37:25 +09:00
|
|
|
font-size: 12px;
|
|
|
|
animation: blink 1s infinite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|