2020-07-11 03:13:11 +02:00
|
|
|
<template>
|
2021-12-03 14:09:40 +01:00
|
|
|
<div class="mk-deck" :class="[{ isMobile }, `${deckStore.reactiveState.columnAlign.value}`]" :style="{ '--deckMargin': deckStore.reactiveState.columnMargin.value + 'px' }"
|
2021-11-19 11:36:12 +01:00
|
|
|
@contextmenu.self.prevent="onContextmenu"
|
2020-12-26 14:41:00 +01:00
|
|
|
>
|
2021-12-03 14:09:40 +01:00
|
|
|
<XSidebar v-if="!isMobile"/>
|
2020-07-11 03:13:11 +02:00
|
|
|
|
|
|
|
<template v-for="ids in layout">
|
2020-12-26 10:33:54 +01:00
|
|
|
<!-- sectionを利用しているのは、deck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
|
|
|
|
<section v-if="ids.length > 1"
|
|
|
|
class="folder column"
|
2020-12-29 09:40:53 +01:00
|
|
|
:style="columns.filter(c => ids.includes(c.id)).some(c => c.flexible) ? { flex: 1, minWidth: '350px' } : { width: Math.max(...columns.filter(c => ids.includes(c.id)).map(c => c.width)) + 'px' }"
|
2020-12-26 10:33:54 +01:00
|
|
|
>
|
2020-12-05 04:50:09 +01:00
|
|
|
<DeckColumnCore v-for="id in ids" :ref="id" :key="id" :column="columns.find(c => c.id === id)" :is-stacked="true" @parent-focus="moveFocus(id, $event)"/>
|
2020-12-26 10:33:54 +01:00
|
|
|
</section>
|
|
|
|
<DeckColumnCore v-else
|
|
|
|
:ref="ids[0]"
|
|
|
|
:key="ids[0]"
|
2021-11-19 11:36:12 +01:00
|
|
|
class="column"
|
2020-12-26 10:33:54 +01:00
|
|
|
:column="columns.find(c => c.id === ids[0])"
|
2020-12-28 11:57:09 +01:00
|
|
|
:style="columns.find(c => c.id === ids[0]).flexible ? { flex: 1, minWidth: '350px' } : { width: columns.find(c => c.id === ids[0]).width + 'px' }"
|
2021-11-19 11:36:12 +01:00
|
|
|
@parent-focus="moveFocus(ids[0], $event)"
|
2020-12-26 10:33:54 +01:00
|
|
|
/>
|
2020-07-11 03:13:11 +02:00
|
|
|
</template>
|
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
<div v-if="isMobile" class="buttons">
|
|
|
|
<button class="button nav _button" @click="drawerMenuShowing = true"><i class="fas fa-bars"></i><span v-if="menuIndicated" class="indicator"><i class="fas fa-circle"></i></span></button>
|
|
|
|
<button class="button home _button" @click="$router.push('/')"><i class="fas fa-home"></i></button>
|
|
|
|
<button class="button notifications _button" @click="$router.push('/my/notifications')"><i class="fas fa-bell"></i><span v-if="$i.hasUnreadNotification" class="indicator"><i class="fas fa-circle"></i></span></button>
|
|
|
|
<button class="button post _button" @click="post()"><i class="fas fa-pencil-alt"></i></button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<transition name="menu-back">
|
|
|
|
<div v-if="drawerMenuShowing"
|
|
|
|
class="menu-back _modalBg"
|
|
|
|
@click="drawerMenuShowing = false"
|
|
|
|
@touchstart.passive="drawerMenuShowing = false"
|
|
|
|
></div>
|
|
|
|
</transition>
|
|
|
|
|
|
|
|
<transition name="menu">
|
|
|
|
<XDrawerMenu v-if="drawerMenuShowing" class="menu"/>
|
|
|
|
</transition>
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2020-10-24 18:21:41 +02:00
|
|
|
<XCommon/>
|
2020-07-11 03:13:11 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-12-03 14:09:40 +01:00
|
|
|
import { computed, defineComponent, provide, ref, watch } from 'vue';
|
2020-07-11 03:13:11 +02:00
|
|
|
import { v4 as uuid } from 'uuid';
|
2021-11-11 18:02:25 +01:00
|
|
|
import DeckColumnCore from '@/ui/deck/column-core.vue';
|
|
|
|
import XSidebar from '@/ui/_common_/sidebar.vue';
|
2021-12-03 14:09:40 +01:00
|
|
|
import XDrawerMenu from '@/ui/_common_/sidebar-for-mobile.vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import { getScrollContainer } from '@/scripts/scroll';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { menuDef } from '@/menu';
|
2020-10-24 18:21:41 +02:00
|
|
|
import XCommon from './_common_/common.vue';
|
2021-12-03 14:09:40 +01:00
|
|
|
import { deckStore, addColumn as addColumnToStore, loadDeck } from './deck/deck-store';
|
|
|
|
import { useRoute } from 'vue-router';
|
|
|
|
import { $i } from '@/account';
|
|
|
|
import { i18n } from '@/i18n';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
2020-07-11 03:13:11 +02:00
|
|
|
components: {
|
2020-10-24 18:21:41 +02:00
|
|
|
XCommon,
|
2020-07-11 03:13:11 +02:00
|
|
|
XSidebar,
|
2021-12-03 14:09:40 +01:00
|
|
|
XDrawerMenu,
|
2020-07-11 03:13:11 +02:00
|
|
|
DeckColumnCore,
|
|
|
|
},
|
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
setup() {
|
|
|
|
const isMobile = ref(window.innerWidth <= 500);
|
|
|
|
window.addEventListener('resize', () => {
|
|
|
|
isMobile.value = window.innerWidth <= 500;
|
|
|
|
});
|
2020-12-27 10:13:50 +01:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
const drawerMenuShowing = ref(false);
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
const route = useRoute();
|
|
|
|
watch(route, () => {
|
|
|
|
drawerMenuShowing.value = false;
|
|
|
|
});
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
const columns = deckStore.reactiveState.columns;
|
2021-12-18 10:11:45 +01:00
|
|
|
const layout = deckStore.reactiveState.layout;
|
2021-12-03 14:09:40 +01:00
|
|
|
const menuIndicated = computed(() => {
|
|
|
|
if ($i == null) return false;
|
|
|
|
for (const def in menuDef) {
|
|
|
|
if (menuDef[def].indicated) return true;
|
2020-07-17 14:53:34 +02:00
|
|
|
}
|
2021-12-03 14:09:40 +01:00
|
|
|
return false;
|
|
|
|
});
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
const addColumn = async (ev) => {
|
2020-07-11 03:13:11 +02:00
|
|
|
const columns = [
|
2020-12-26 10:33:54 +01:00
|
|
|
'main',
|
2020-07-11 03:13:11 +02:00
|
|
|
'widgets',
|
|
|
|
'notifications',
|
|
|
|
'tl',
|
|
|
|
'antenna',
|
|
|
|
'list',
|
|
|
|
'mentions',
|
|
|
|
'direct',
|
|
|
|
];
|
|
|
|
|
2021-11-18 10:45:58 +01:00
|
|
|
const { canceled, result: column } = await os.select({
|
2021-12-03 14:09:40 +01:00
|
|
|
title: i18n.locale._deck.addColumn,
|
2021-11-18 10:45:58 +01:00
|
|
|
items: columns.map(column => ({
|
2021-12-03 14:09:40 +01:00
|
|
|
value: column, text: i18n.t('_deck._columns.' + column)
|
2021-11-18 10:45:58 +01:00
|
|
|
}))
|
2020-07-11 03:13:11 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
addColumnToStore({
|
2020-07-11 03:13:11 +02:00
|
|
|
type: column,
|
|
|
|
id: uuid(),
|
2021-12-03 14:09:40 +01:00
|
|
|
name: i18n.t('_deck._columns.' + column),
|
2020-07-11 03:13:11 +02:00
|
|
|
width: 330,
|
|
|
|
});
|
2021-12-03 14:09:40 +01:00
|
|
|
};
|
2020-12-26 10:33:54 +01:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
const onContextmenu = (ev) => {
|
2020-12-26 10:33:54 +01:00
|
|
|
os.contextMenu([{
|
2021-12-03 14:09:40 +01:00
|
|
|
text: i18n.locale._deck.addColumn,
|
2020-12-26 10:33:54 +01:00
|
|
|
icon: null,
|
2021-12-03 14:09:40 +01:00
|
|
|
action: addColumn
|
|
|
|
}], ev);
|
|
|
|
};
|
|
|
|
|
|
|
|
provide('shouldSpacerMin', true);
|
|
|
|
if (deckStore.state.navWindow) {
|
|
|
|
provide('navHook', (url) => {
|
|
|
|
os.pageWindow(url);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
document.documentElement.style.overflowY = 'hidden';
|
|
|
|
document.documentElement.style.scrollBehavior = 'auto';
|
|
|
|
window.addEventListener('wheel', (ev) => {
|
|
|
|
if (getScrollContainer(ev.target) == null) {
|
|
|
|
document.documentElement.scrollLeft += ev.deltaY > 0 ? 96 : -96;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
loadDeck();
|
|
|
|
|
|
|
|
return {
|
|
|
|
isMobile,
|
|
|
|
deckStore,
|
|
|
|
drawerMenuShowing,
|
|
|
|
columns,
|
|
|
|
layout,
|
|
|
|
menuIndicated,
|
|
|
|
onContextmenu,
|
|
|
|
wallpaper: localStorage.getItem('wallpaper') != null,
|
|
|
|
post: os.post,
|
|
|
|
};
|
|
|
|
},
|
2020-07-11 03:13:11 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-12-03 14:09:40 +01:00
|
|
|
.menu-enter-active,
|
|
|
|
.menu-leave-active {
|
|
|
|
opacity: 1;
|
|
|
|
transform: translateX(0);
|
|
|
|
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
.menu-enter-from,
|
|
|
|
.menu-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(-240px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-back-enter-active,
|
|
|
|
.menu-back-leave-active {
|
|
|
|
opacity: 1;
|
|
|
|
transition: opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
.menu-back-enter-from,
|
|
|
|
.menu-back-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
.mk-deck {
|
|
|
|
$nav-hide-threshold: 650px; // TODO: どこかに集約したい
|
|
|
|
|
2020-12-26 14:41:00 +01:00
|
|
|
// TODO: ここではなくて、各カラムで自身の幅に応じて上書きするようにしたい
|
2020-07-11 03:13:11 +02:00
|
|
|
--margin: var(--marginHalf);
|
|
|
|
|
|
|
|
display: flex;
|
2020-07-15 11:22:19 +02:00
|
|
|
// ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
|
|
height: calc(var(--vh, 1vh) * 100);
|
2020-07-11 03:13:11 +02:00
|
|
|
box-sizing: border-box;
|
|
|
|
flex: 1;
|
2020-12-26 14:41:00 +01:00
|
|
|
padding: var(--deckMargin);
|
2020-07-11 03:13:11 +02:00
|
|
|
|
|
|
|
&.center {
|
|
|
|
> .column:first-of-type {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
|
2020-12-26 10:33:54 +01:00
|
|
|
> .column:last-of-type {
|
2020-07-11 03:13:11 +02:00
|
|
|
margin-right: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
&.isMobile {
|
|
|
|
padding-bottom: 100px;
|
|
|
|
}
|
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
> .column {
|
|
|
|
flex-shrink: 0;
|
2020-12-26 14:41:00 +01:00
|
|
|
margin-right: var(--deckMargin);
|
2020-07-11 03:13:11 +02:00
|
|
|
|
|
|
|
&.folder {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
> *:not(:last-child) {
|
2020-12-26 14:41:00 +01:00
|
|
|
margin-bottom: var(--deckMargin);
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
> .buttons {
|
2020-07-11 03:13:11 +02:00
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
2021-12-03 14:09:40 +01:00
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
padding: 16px;
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
> .button {
|
|
|
|
position: relative;
|
|
|
|
flex: 1;
|
|
|
|
padding: 0;
|
|
|
|
margin: auto;
|
|
|
|
height: 64px;
|
|
|
|
border-radius: 8px;
|
|
|
|
background: var(--panel);
|
|
|
|
color: var(--fg);
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
&:not(:last-child) {
|
|
|
|
margin-right: 12px;
|
|
|
|
}
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
@media (max-width: 400px) {
|
|
|
|
height: 60px;
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 03:13:11 +02:00
|
|
|
|
2021-12-03 14:09:40 +01:00
|
|
|
&:hover {
|
|
|
|
background: var(--X2);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .indicator {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
color: var(--indicator);
|
|
|
|
font-size: 16px;
|
|
|
|
animation: blink 1s infinite;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:first-child {
|
|
|
|
margin-left: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
> * {
|
|
|
|
font-size: 22px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:disabled {
|
|
|
|
cursor: default;
|
|
|
|
|
|
|
|
> * {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
}
|
2021-12-03 14:09:40 +01:00
|
|
|
|
|
|
|
> .menu-back {
|
|
|
|
z-index: 1001;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .menu {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 1001;
|
|
|
|
// ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
|
|
height: calc(var(--vh, 1vh) * 100);
|
|
|
|
width: 240px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
overflow: auto;
|
2021-12-03 14:22:08 +01:00
|
|
|
overscroll-behavior: contain;
|
2021-12-03 14:09:40 +01:00
|
|
|
background: var(--bg);
|
|
|
|
}
|
2020-07-11 03:13:11 +02:00
|
|
|
}
|
|
|
|
</style>
|