2018-06-05 21:36:21 +09:00
|
|
|
<template>
|
|
|
|
<mk-ui :class="$style.root">
|
2019-02-26 14:02:23 +09:00
|
|
|
<div class="qlvquzbjribqcaozciifydkngcwtyzje" ref="body" :style="style" :class="`${$store.state.device.deckColumnAlign} ${$store.state.device.deckColumnWidth}`" v-hotkey.global="keymap">
|
2018-06-08 04:21:06 +09:00
|
|
|
<template v-for="ids in layout">
|
|
|
|
<div v-if="ids.length > 1" class="folder">
|
|
|
|
<template v-for="id, i in ids">
|
2018-10-20 02:40:37 +09:00
|
|
|
<x-column-core :ref="id" :key="id" :column="columns.find(c => c.id == id)" :is-stacked="true" @parentFocus="moveFocus(id, $event)"/>
|
2018-06-08 04:21:06 +09:00
|
|
|
</template>
|
|
|
|
</div>
|
2018-10-20 02:40:37 +09:00
|
|
|
<x-column-core v-else :ref="ids[0]" :key="ids[0]" :column="columns.find(c => c.id == ids[0])" @parentFocus="moveFocus(ids[0], $event)"/>
|
2018-06-06 03:12:06 +09:00
|
|
|
</template>
|
2019-02-15 05:08:59 +09:00
|
|
|
<router-view></router-view>
|
2018-11-09 03:44:35 +09:00
|
|
|
<button ref="add" @click="add" :title="$t('@deck.add-column')"><fa icon="plus"/></button>
|
2018-06-05 21:36:21 +09:00
|
|
|
</div>
|
|
|
|
</mk-ui>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2019-02-15 05:08:59 +09:00
|
|
|
import i18n from '../../../i18n';
|
2018-06-08 04:21:06 +09:00
|
|
|
import XColumnCore from './deck.column-core.vue';
|
2019-02-15 05:08:59 +09:00
|
|
|
import Menu from '../../../common/views/components/menu.vue';
|
2018-10-19 06:18:33 +09:00
|
|
|
|
2018-06-06 03:12:06 +09:00
|
|
|
import * as uuid from 'uuid';
|
2018-06-05 21:36:21 +09:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-09 03:44:35 +09:00
|
|
|
i18n: i18n('deck'),
|
2018-06-05 21:36:21 +09:00
|
|
|
components: {
|
2019-02-15 05:08:59 +09:00
|
|
|
XColumnCore
|
2018-06-06 03:12:06 +09:00
|
|
|
},
|
2018-06-07 01:00:38 +09:00
|
|
|
|
2018-06-06 03:12:06 +09:00
|
|
|
computed: {
|
2018-06-08 04:21:06 +09:00
|
|
|
columns(): any[] {
|
2019-02-25 19:45:00 +09:00
|
|
|
if (this.$store.state.device.deck == null) return [];
|
|
|
|
return this.$store.state.device.deck.columns;
|
2018-06-08 04:21:06 +09:00
|
|
|
},
|
2018-10-19 06:18:33 +09:00
|
|
|
|
2018-06-08 04:21:06 +09:00
|
|
|
layout(): any[] {
|
2019-02-25 19:45:00 +09:00
|
|
|
if (this.$store.state.device.deck == null) return [];
|
|
|
|
if (this.$store.state.device.deck.layout == null) return this.$store.state.device.deck.columns.map(c => [c.id]);
|
|
|
|
return this.$store.state.device.deck.layout;
|
2018-09-22 20:11:13 +09:00
|
|
|
},
|
2018-10-19 06:18:33 +09:00
|
|
|
|
2018-09-22 20:11:13 +09:00
|
|
|
style(): any {
|
|
|
|
return {
|
|
|
|
height: `calc(100vh - ${this.$store.state.uiHeaderHeight}px)`
|
|
|
|
};
|
2018-10-19 06:18:33 +09:00
|
|
|
},
|
|
|
|
|
2018-10-19 15:03:23 +09:00
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
't': this.focus
|
|
|
|
};
|
2018-06-06 03:12:06 +09:00
|
|
|
}
|
|
|
|
},
|
2018-06-07 01:00:38 +09:00
|
|
|
|
2019-02-15 15:06:15 +09:00
|
|
|
watch: {
|
|
|
|
$route() {
|
|
|
|
if (this.$route.name == 'index') return;
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$refs.body.scrollTo({
|
|
|
|
left: this.$refs.body.scrollWidth - this.$refs.body.clientWidth,
|
|
|
|
behavior: 'smooth'
|
2018-10-20 07:21:22 +09:00
|
|
|
});
|
2019-02-15 15:06:15 +09:00
|
|
|
});
|
|
|
|
}
|
2018-10-20 07:21:22 +09:00
|
|
|
},
|
|
|
|
|
2018-06-08 04:21:06 +09:00
|
|
|
provide() {
|
|
|
|
return {
|
2019-02-26 05:22:21 +09:00
|
|
|
inDeck: true,
|
2019-02-25 19:45:00 +09:00
|
|
|
getColumnVm: this.getColumnVm,
|
|
|
|
narrow: true
|
2018-06-08 04:21:06 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2018-06-06 03:12:06 +09:00
|
|
|
created() {
|
2019-02-25 19:45:00 +09:00
|
|
|
if (this.$store.state.device.deck == null) {
|
2018-06-06 03:12:06 +09:00
|
|
|
const deck = {
|
|
|
|
columns: [/*{
|
|
|
|
type: 'widgets',
|
|
|
|
widgets: []
|
|
|
|
}, */{
|
|
|
|
id: uuid(),
|
2019-02-25 19:45:00 +09:00
|
|
|
type: 'home',
|
|
|
|
name: null,
|
2018-06-06 03:12:06 +09:00
|
|
|
}, {
|
|
|
|
id: uuid(),
|
2019-02-25 19:45:00 +09:00
|
|
|
type: 'notifications',
|
|
|
|
name: null,
|
2018-06-06 03:12:06 +09:00
|
|
|
}, {
|
|
|
|
id: uuid(),
|
2019-02-25 19:45:00 +09:00
|
|
|
type: 'local',
|
|
|
|
name: null,
|
2018-06-06 03:12:06 +09:00
|
|
|
}, {
|
|
|
|
id: uuid(),
|
2019-02-25 19:45:00 +09:00
|
|
|
type: 'global',
|
|
|
|
name: null,
|
2018-06-06 03:12:06 +09:00
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
2018-06-08 04:21:06 +09:00
|
|
|
deck.layout = deck.columns.map(c => [c.id]);
|
|
|
|
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/set', {
|
2018-06-06 03:12:06 +09:00
|
|
|
key: 'deck',
|
|
|
|
value: deck
|
|
|
|
});
|
|
|
|
}
|
2018-06-06 05:18:08 +09:00
|
|
|
},
|
|
|
|
|
2018-06-07 01:00:38 +09:00
|
|
|
mounted() {
|
2018-11-09 08:26:32 +09:00
|
|
|
document.title = this.$root.instanceName;
|
2018-06-07 01:00:38 +09:00
|
|
|
document.documentElement.style.overflow = 'hidden';
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
document.documentElement.style.overflow = 'auto';
|
|
|
|
},
|
|
|
|
|
2018-06-06 05:18:08 +09:00
|
|
|
methods: {
|
2018-06-08 04:21:06 +09:00
|
|
|
getColumnVm(id) {
|
|
|
|
return this.$refs[id][0];
|
|
|
|
},
|
|
|
|
|
2018-06-06 05:18:08 +09:00
|
|
|
add() {
|
2018-11-09 08:13:34 +09:00
|
|
|
this.$root.new(Menu, {
|
2018-06-06 05:18:08 +09:00
|
|
|
source: this.$refs.add,
|
|
|
|
items: [{
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: 'home',
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.home'),
|
2018-06-08 11:46:45 +09:00
|
|
|
action: () => {
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-06-06 05:18:08 +09:00
|
|
|
id: uuid(),
|
|
|
|
type: 'home'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: ['far', 'comments'],
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.local'),
|
2018-06-08 11:46:45 +09:00
|
|
|
action: () => {
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-06-06 05:18:08 +09:00
|
|
|
id: uuid(),
|
|
|
|
type: 'local'
|
|
|
|
});
|
|
|
|
}
|
2018-07-11 13:43:09 +09:00
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: 'share-alt',
|
2019-04-08 23:05:41 +09:00
|
|
|
text: this.$t('@deck.hybrid'),
|
2018-07-11 13:43:09 +09:00
|
|
|
action: () => {
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-07-11 13:43:09 +09:00
|
|
|
id: uuid(),
|
2019-04-08 23:05:41 +09:00
|
|
|
type: 'hybrid'
|
2018-07-11 13:43:09 +09:00
|
|
|
});
|
|
|
|
}
|
2018-06-06 05:18:08 +09:00
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: 'globe',
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.global'),
|
2018-06-08 11:46:45 +09:00
|
|
|
action: () => {
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-06-06 05:18:08 +09:00
|
|
|
id: uuid(),
|
|
|
|
type: 'global'
|
|
|
|
});
|
|
|
|
}
|
2018-09-16 23:15:02 +09:00
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: 'at',
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.mentions'),
|
2018-09-16 23:15:02 +09:00
|
|
|
action: () => {
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-09-16 23:15:02 +09:00
|
|
|
id: uuid(),
|
|
|
|
type: 'mentions'
|
|
|
|
});
|
|
|
|
}
|
2018-09-18 02:14:12 +09:00
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: ['far', 'envelope'],
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.direct'),
|
2018-09-18 02:14:12 +09:00
|
|
|
action: () => {
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-09-18 02:14:12 +09:00
|
|
|
id: uuid(),
|
|
|
|
type: 'direct'
|
|
|
|
});
|
|
|
|
}
|
2018-06-06 05:18:08 +09:00
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: 'list',
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.list'),
|
2019-02-25 19:45:00 +09:00
|
|
|
action: async () => {
|
|
|
|
const lists = await this.$root.api('users/lists/list');
|
|
|
|
const { canceled, result: listId } = await this.$root.dialog({
|
|
|
|
type: null,
|
|
|
|
title: this.$t('@deck.select-list'),
|
|
|
|
select: {
|
|
|
|
items: lists.map(list => ({
|
2019-04-07 21:50:36 +09:00
|
|
|
value: list.id, text: list.name
|
2019-02-25 19:45:00 +09:00
|
|
|
}))
|
|
|
|
},
|
|
|
|
showCancelButton: true
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
this.$store.commit('device/addDeckColumn', {
|
|
|
|
id: uuid(),
|
|
|
|
type: 'list',
|
|
|
|
list: lists.find(l => l.id === listId)
|
2018-06-06 05:18:08 +09:00
|
|
|
});
|
|
|
|
}
|
2018-09-17 09:00:20 +09:00
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: 'hashtag',
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.hashtag'),
|
2018-09-17 09:00:20 +09:00
|
|
|
action: () => {
|
2018-12-02 20:10:53 +09:00
|
|
|
this.$root.dialog({
|
|
|
|
title: this.$t('enter-hashtag-tl-title'),
|
|
|
|
input: true
|
|
|
|
}).then(({ canceled, result: title }) => {
|
|
|
|
if (canceled) return;
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-09-17 09:00:20 +09:00
|
|
|
id: uuid(),
|
|
|
|
type: 'hashtag',
|
|
|
|
tagTlId: this.$store.state.settings.tagTimelines.find(x => x.title == title).id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2018-06-06 05:18:08 +09:00
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: ['far', 'bell'],
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.notifications'),
|
2018-06-08 11:46:45 +09:00
|
|
|
action: () => {
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-06-06 05:18:08 +09:00
|
|
|
id: uuid(),
|
|
|
|
type: 'notifications'
|
|
|
|
});
|
|
|
|
}
|
2018-06-06 19:22:45 +09:00
|
|
|
}, {
|
2018-11-06 01:40:11 +09:00
|
|
|
icon: 'calculator',
|
2018-11-09 03:44:35 +09:00
|
|
|
text: this.$t('@deck.widgets'),
|
2018-06-08 11:46:45 +09:00
|
|
|
action: () => {
|
2019-02-25 19:45:00 +09:00
|
|
|
this.$store.commit('device/addDeckColumn', {
|
2018-06-06 19:22:45 +09:00
|
|
|
id: uuid(),
|
|
|
|
type: 'widgets',
|
|
|
|
widgets: []
|
|
|
|
});
|
|
|
|
}
|
2018-06-06 05:18:08 +09:00
|
|
|
}]
|
|
|
|
});
|
2018-10-19 15:03:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
// Flatten array of arrays
|
|
|
|
const ids = [].concat.apply([], this.layout);
|
2018-10-20 02:40:37 +09:00
|
|
|
const firstTl = ids.find(id => this.isTlColumn(id));
|
2018-10-19 15:03:23 +09:00
|
|
|
|
|
|
|
if (firstTl) {
|
|
|
|
this.$refs[firstTl][0].focus();
|
|
|
|
}
|
2018-10-20 02:40:37 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
moveFocus(id, direction) {
|
|
|
|
let targetColumn;
|
|
|
|
|
|
|
|
if (direction == 'right') {
|
|
|
|
const currentColumnIndex = this.layout.findIndex(ids => ids.includes(id));
|
|
|
|
this.layout.some((ids, i) => {
|
|
|
|
if (i <= currentColumnIndex) return false;
|
|
|
|
const tl = ids.find(id => this.isTlColumn(id));
|
|
|
|
if (tl) {
|
|
|
|
targetColumn = tl;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (direction == 'left') {
|
|
|
|
const currentColumnIndex = [...this.layout].reverse().findIndex(ids => ids.includes(id));
|
|
|
|
[...this.layout].reverse().some((ids, i) => {
|
|
|
|
if (i <= currentColumnIndex) return false;
|
|
|
|
const tl = ids.find(id => this.isTlColumn(id));
|
|
|
|
if (tl) {
|
|
|
|
targetColumn = tl;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (direction == 'down') {
|
|
|
|
const currentColumn = this.layout.find(ids => ids.includes(id));
|
|
|
|
const currentIndex = currentColumn.indexOf(id);
|
|
|
|
currentColumn.some((_id, i) => {
|
|
|
|
if (i <= currentIndex) return false;
|
|
|
|
if (this.isTlColumn(_id)) {
|
|
|
|
targetColumn = _id;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (direction == 'up') {
|
|
|
|
const currentColumn = [...this.layout.find(ids => ids.includes(id))].reverse();
|
|
|
|
const currentIndex = currentColumn.indexOf(id);
|
|
|
|
currentColumn.some((_id, i) => {
|
|
|
|
if (i <= currentIndex) return false;
|
|
|
|
if (this.isTlColumn(_id)) {
|
|
|
|
targetColumn = _id;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (targetColumn) {
|
|
|
|
this.$refs[targetColumn][0].focus();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isTlColumn(id) {
|
|
|
|
const column = this.columns.find(c => c.id === id);
|
2019-04-08 23:05:41 +09:00
|
|
|
return ['home', 'local', 'hybrid', 'global', 'list', 'hashtag', 'mentions', 'direct'].includes(column.type);
|
2018-06-06 05:18:08 +09:00
|
|
|
}
|
2018-06-05 21:36:21 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" module>
|
|
|
|
.root
|
|
|
|
height 100vh
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 15:34:34 +09:00
|
|
|
.qlvquzbjribqcaozciifydkngcwtyzje
|
2018-06-05 21:36:21 +09:00
|
|
|
display flex
|
|
|
|
flex 1
|
2018-06-05 21:44:02 +09:00
|
|
|
padding 16px 0 16px 16px
|
|
|
|
overflow auto
|
2019-02-25 19:45:00 +09:00
|
|
|
overflow-y hidden
|
|
|
|
-webkit-overflow-scrolling touch
|
2018-06-05 21:36:21 +09:00
|
|
|
|
2019-02-26 14:02:23 +09:00
|
|
|
@media (max-width 500px)
|
|
|
|
padding 8px 0 8px 8px
|
2019-02-26 05:22:21 +09:00
|
|
|
|
2018-06-06 04:00:48 +09:00
|
|
|
> div
|
2018-06-07 01:17:29 +09:00
|
|
|
margin-right 8px
|
2018-12-06 11:11:46 +09:00
|
|
|
width 330px
|
|
|
|
min-width 330px
|
2018-06-06 04:00:48 +09:00
|
|
|
|
|
|
|
&:last-of-type
|
|
|
|
margin-right 0
|
|
|
|
|
2018-06-08 04:21:06 +09:00
|
|
|
&.folder
|
|
|
|
display flex
|
|
|
|
flex-direction column
|
|
|
|
|
|
|
|
> *:not(:last-child)
|
|
|
|
margin-bottom 8px
|
|
|
|
|
2018-12-06 11:11:46 +09:00
|
|
|
&.narrow
|
|
|
|
> div
|
|
|
|
width 303px
|
|
|
|
min-width 303px
|
|
|
|
|
|
|
|
&.narrower
|
|
|
|
> div
|
|
|
|
width 316.5px
|
|
|
|
min-width 316.5px
|
|
|
|
|
|
|
|
&.wider
|
|
|
|
> div
|
|
|
|
width 343.5px
|
|
|
|
min-width 343.5px
|
|
|
|
|
|
|
|
&.wide
|
|
|
|
> div
|
|
|
|
width 357px
|
|
|
|
min-width 357px
|
|
|
|
|
2018-10-19 06:47:55 +09:00
|
|
|
&.center
|
|
|
|
> *
|
|
|
|
&:first-child
|
|
|
|
margin-left auto
|
2018-06-07 05:14:37 +09:00
|
|
|
|
2018-10-19 06:47:55 +09:00
|
|
|
&:last-child
|
|
|
|
margin-right auto
|
2018-06-07 05:14:37 +09:00
|
|
|
|
2018-12-06 11:11:46 +09:00
|
|
|
&.:not(.flexible)
|
|
|
|
> *
|
|
|
|
flex-grow 0
|
|
|
|
flex-shrink 0
|
|
|
|
|
|
|
|
&.flexible
|
|
|
|
> *
|
|
|
|
flex-grow 1
|
|
|
|
flex-shrink 0
|
|
|
|
|
2018-06-06 04:00:48 +09:00
|
|
|
> button
|
|
|
|
padding 0 16px
|
2018-09-28 15:34:34 +09:00
|
|
|
color var(--faceTextButton)
|
2018-12-06 11:11:46 +09:00
|
|
|
flex-grow 0 !important
|
2018-06-06 04:00:48 +09:00
|
|
|
|
|
|
|
&:hover
|
2018-09-28 15:34:34 +09:00
|
|
|
color var(--faceTextButtonHover)
|
2018-06-06 04:00:48 +09:00
|
|
|
|
|
|
|
&:active
|
2018-09-28 15:34:34 +09:00
|
|
|
color var(--faceTextButtonActive)
|
2018-06-05 21:36:21 +09:00
|
|
|
|
|
|
|
</style>
|