2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2020-12-27 17:04:41 +09:00
|
|
|
<div class="mk-app" :class="{ wallpaper }">
|
2020-10-17 20:12:00 +09:00
|
|
|
<XSidebar ref="nav" class="sidebar"/>
|
|
|
|
|
2020-12-29 21:18:35 +09:00
|
|
|
<div class="contents" ref="contents" :class="{ withHeader: $store.state.titlebar }" @contextmenu.stop="onContextmenu">
|
2020-12-29 11:47:36 +09:00
|
|
|
<header v-if="$store.state.titlebar" class="header" ref="header" @click="onHeaderClick">
|
2020-10-17 20:12:00 +09:00
|
|
|
<XHeader :info="pageInfo"/>
|
|
|
|
</header>
|
|
|
|
<main ref="main">
|
|
|
|
<div class="content">
|
|
|
|
<router-view v-slot="{ Component }">
|
2020-12-19 10:55:52 +09:00
|
|
|
<transition :name="$store.state.animation ? 'page' : ''" mode="out-in" @enter="onTransition">
|
2020-10-17 20:12:00 +09:00
|
|
|
<keep-alive :include="['timeline']">
|
|
|
|
<component :is="Component" :ref="changePage"/>
|
|
|
|
</keep-alive>
|
|
|
|
</transition>
|
|
|
|
</router-view>
|
|
|
|
</div>
|
|
|
|
<div class="spacer"></div>
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
|
2020-10-25 01:21:41 +09:00
|
|
|
<XSide v-if="isDesktop" class="side" ref="side"/>
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
<div v-if="isDesktop" class="widgets">
|
|
|
|
<div ref="widgetsSpacer"></div>
|
|
|
|
<XWidgets @mounted="attachSticky"/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="buttons" :class="{ navHidden }">
|
|
|
|
<button class="button nav _button" @click="showNav" ref="navButton"><Fa :icon="faBars"/><i v-if="navIndicated"><Fa :icon="faCircle"/></i></button>
|
2020-12-29 17:31:46 +09:00
|
|
|
<button class="button home _button" @click="$route.name === 'index' ? top() : $router.push('/')"><Fa :icon="faHome"/></button>
|
2020-12-19 10:55:52 +09:00
|
|
|
<button class="button notifications _button" @click="$router.push('/my/notifications')"><Fa :icon="faBell"/><i v-if="$i.hasUnreadNotification"><Fa :icon="faCircle"/></i></button>
|
2020-10-17 20:12:00 +09:00
|
|
|
<button class="button widget _button" @click="widgetsShowing = true"><Fa :icon="faLayerGroup"/></button>
|
2020-12-27 10:42:38 +09:00
|
|
|
<button class="button post _button" @click="post"><Fa :icon="faPencilAlt"/></button>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<button class="widgetButton _button" :class="{ navHidden }" @click="widgetsShowing = true"><Fa :icon="faLayerGroup"/></button>
|
|
|
|
|
|
|
|
<transition name="tray-back">
|
|
|
|
<div class="tray-back _modalBg"
|
|
|
|
v-if="widgetsShowing"
|
|
|
|
@click="widgetsShowing = false"
|
|
|
|
@touchstart.passive="widgetsShowing = false"
|
|
|
|
></div>
|
|
|
|
</transition>
|
|
|
|
|
|
|
|
<transition name="tray">
|
|
|
|
<XWidgets v-if="widgetsShowing" class="tray"/>
|
|
|
|
</transition>
|
|
|
|
|
2020-10-25 01:21:41 +09:00
|
|
|
<XCommon/>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-12-30 11:01:33 +09:00
|
|
|
import { defineComponent, defineAsyncComponent } from 'vue';
|
2020-12-27 10:42:38 +09:00
|
|
|
import { faLayerGroup, faBars, faHome, faCircle, faWindowMaximize, faColumns, faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
2020-10-17 20:12:00 +09:00
|
|
|
import { faBell } from '@fortawesome/free-regular-svg-icons';
|
2020-12-30 11:01:33 +09:00
|
|
|
import { instanceName } from '@/config';
|
2020-10-17 20:12:00 +09:00
|
|
|
import { StickySidebar } from '@/scripts/sticky-sidebar';
|
|
|
|
import XSidebar from '@/components/sidebar.vue';
|
2020-10-25 01:21:41 +09:00
|
|
|
import XCommon from './_common_/common.vue';
|
2020-10-17 20:12:00 +09:00
|
|
|
import XHeader from './_common_/header.vue';
|
2020-10-25 01:21:41 +09:00
|
|
|
import XSide from './default.side.vue';
|
2020-10-17 20:12:00 +09:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { sidebarDef } from '@/sidebar';
|
|
|
|
|
|
|
|
const DESKTOP_THRESHOLD = 1100;
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-10-25 01:21:41 +09:00
|
|
|
XCommon,
|
2020-10-17 20:12:00 +09:00
|
|
|
XSidebar,
|
|
|
|
XHeader,
|
|
|
|
XWidgets: defineAsyncComponent(() => import('./default.widgets.vue')),
|
2020-10-25 01:21:41 +09:00
|
|
|
XSide, // NOTE: dynamic importするとAsyncComponentWrapperが間に入るせいでref取得できなくて面倒になる
|
|
|
|
},
|
|
|
|
|
|
|
|
provide() {
|
|
|
|
return {
|
2020-10-25 15:45:47 +09:00
|
|
|
sideViewHook: this.isDesktop ? (url) => {
|
2020-10-25 01:21:41 +09:00
|
|
|
this.$refs.side.navigate(url);
|
2020-10-25 15:45:47 +09:00
|
|
|
} : null
|
2020-10-25 01:21:41 +09:00
|
|
|
};
|
2020-10-17 20:12:00 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
pageInfo: null,
|
|
|
|
isDesktop: window.innerWidth >= DESKTOP_THRESHOLD,
|
|
|
|
menuDef: sidebarDef,
|
|
|
|
navHidden: false,
|
|
|
|
widgetsShowing: false,
|
|
|
|
wallpaper: localStorage.getItem('wallpaper') != null,
|
2020-12-27 10:42:38 +09:00
|
|
|
faLayerGroup, faBars, faBell, faHome, faCircle, faPencilAlt,
|
2020-10-17 20:12:00 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
navIndicated(): boolean {
|
|
|
|
for (const def in this.menuDef) {
|
|
|
|
if (def === 'notifications') continue; // 通知は下にボタンとして表示されてるから
|
|
|
|
if (this.menuDef[def].indicated) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
document.documentElement.style.overflowY = 'scroll';
|
|
|
|
|
2020-12-19 10:55:52 +09:00
|
|
|
if (this.$store.state.widgets.length === 0) {
|
|
|
|
this.$store.set('widgets', [{
|
2020-10-17 20:12:00 +09:00
|
|
|
name: 'calendar',
|
|
|
|
id: 'a', place: 'right', data: {}
|
|
|
|
}, {
|
|
|
|
name: 'notifications',
|
|
|
|
id: 'b', place: 'right', data: {}
|
|
|
|
}, {
|
|
|
|
name: 'trends',
|
|
|
|
id: 'c', place: 'right', data: {}
|
|
|
|
}]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.adjustUI();
|
|
|
|
|
|
|
|
const ro = new ResizeObserver((entries, observer) => {
|
|
|
|
this.adjustUI();
|
|
|
|
});
|
|
|
|
|
|
|
|
ro.observe(this.$refs.contents);
|
|
|
|
|
|
|
|
window.addEventListener('resize', this.adjustUI, { passive: true });
|
|
|
|
|
|
|
|
if (!this.isDesktop) {
|
|
|
|
window.addEventListener('resize', () => {
|
|
|
|
if (window.innerWidth >= DESKTOP_THRESHOLD) this.isDesktop = true;
|
|
|
|
}, { passive: true });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
changePage(page) {
|
|
|
|
if (page == null) return;
|
|
|
|
if (page.INFO) {
|
|
|
|
this.pageInfo = page.INFO;
|
2020-12-30 11:01:33 +09:00
|
|
|
document.title = `${this.pageInfo.title} | ${instanceName}`;
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
adjustUI() {
|
|
|
|
const navWidth = this.$refs.nav.$el.offsetWidth;
|
|
|
|
this.navHidden = navWidth === 0;
|
|
|
|
if (this.$refs.contents == null) return;
|
|
|
|
const width = this.$refs.contents.offsetWidth;
|
2020-12-29 11:47:36 +09:00
|
|
|
if (this.$refs.header) this.$refs.header.style.width = `${width}px`;
|
2020-10-17 20:12:00 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
showNav() {
|
|
|
|
this.$refs.nav.show();
|
|
|
|
},
|
|
|
|
|
|
|
|
attachSticky(el) {
|
|
|
|
const sticky = new StickySidebar(el, this.$refs.widgetsSpacer);
|
|
|
|
window.addEventListener('scroll', () => {
|
|
|
|
sticky.calc(window.scrollY);
|
|
|
|
}, { passive: true });
|
|
|
|
},
|
|
|
|
|
2020-12-27 10:42:38 +09:00
|
|
|
post() {
|
|
|
|
os.post();
|
|
|
|
},
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
top() {
|
|
|
|
window.scroll({ top: 0, behavior: 'smooth' });
|
|
|
|
},
|
|
|
|
|
|
|
|
onTransition() {
|
|
|
|
if (window._scroll) window._scroll();
|
|
|
|
},
|
|
|
|
|
2020-11-07 12:30:16 +09:00
|
|
|
onHeaderClick() {
|
|
|
|
window.scroll({ top: 0, behavior: 'smooth' });
|
|
|
|
},
|
|
|
|
|
2020-10-25 09:26:19 +09:00
|
|
|
onContextmenu(e) {
|
2021-02-07 00:11:16 +09:00
|
|
|
const isLink = (el: HTMLElement) => {
|
|
|
|
if (el.tagName === 'A') return true;
|
|
|
|
if (el.parentElement) {
|
|
|
|
return isLink(el.parentElement);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if (isLink(e.target)) return;
|
2020-12-29 21:18:35 +09:00
|
|
|
if (['INPUT', 'TEXTAREA'].includes(e.target.tagName) || e.target.attributes['contenteditable']) return;
|
2021-01-11 18:49:39 +09:00
|
|
|
if (window.getSelection().toString() !== '') return;
|
2020-11-03 10:06:19 +09:00
|
|
|
const path = this.$route.path;
|
2020-10-25 09:26:19 +09:00
|
|
|
os.contextMenu([{
|
|
|
|
type: 'label',
|
2020-11-03 10:06:19 +09:00
|
|
|
text: path,
|
2020-10-25 09:26:19 +09:00
|
|
|
}, {
|
|
|
|
icon: faColumns,
|
2020-12-26 10:47:36 +09:00
|
|
|
text: this.$ts.openInSideView,
|
2020-10-25 09:26:19 +09:00
|
|
|
action: () => {
|
2020-11-03 10:06:19 +09:00
|
|
|
this.$refs.side.navigate(path);
|
2020-10-25 09:26:19 +09:00
|
|
|
}
|
|
|
|
}, {
|
|
|
|
icon: faWindowMaximize,
|
2020-12-26 10:47:36 +09:00
|
|
|
text: this.$ts.openInWindow,
|
2020-10-25 09:26:19 +09:00
|
|
|
action: () => {
|
2020-11-03 10:06:19 +09:00
|
|
|
os.pageWindow(path);
|
2020-10-25 09:26:19 +09:00
|
|
|
}
|
|
|
|
}], e);
|
|
|
|
},
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.tray-enter-active,
|
|
|
|
.tray-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);
|
|
|
|
}
|
|
|
|
.tray-enter-from,
|
|
|
|
.tray-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateX(240px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.tray-back-enter-active,
|
|
|
|
.tray-back-leave-active {
|
|
|
|
opacity: 1;
|
|
|
|
transition: opacity 300ms cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
.tray-back-enter-from,
|
|
|
|
.tray-back-leave-active {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.mk-app {
|
2020-10-25 01:21:41 +09:00
|
|
|
$header-height: 58px; // TODO: どこかに集約したい
|
2020-10-17 20:12:00 +09:00
|
|
|
$ui-font-size: 1em; // TODO: どこかに集約したい
|
|
|
|
$widgets-hide-threshold: 1090px;
|
|
|
|
|
|
|
|
// ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
|
|
min-height: calc(var(--vh, 1vh) * 100);
|
|
|
|
box-sizing: border-box;
|
|
|
|
display: flex;
|
|
|
|
|
2020-11-28 13:30:09 +09:00
|
|
|
&.wallpaper {
|
|
|
|
background: var(--wallpaperOverlay);
|
|
|
|
//backdrop-filter: blur(4px);
|
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
> .contents {
|
|
|
|
width: 100%;
|
|
|
|
min-width: 0;
|
2020-12-29 11:47:36 +09:00
|
|
|
|
|
|
|
&.withHeader {
|
|
|
|
padding-top: $header-height;
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
|
|
|
> .header {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
top: 0;
|
|
|
|
height: $header-height;
|
|
|
|
width: 100%;
|
|
|
|
line-height: $header-height;
|
|
|
|
text-align: center;
|
|
|
|
font-weight: bold;
|
|
|
|
//background-color: var(--panel);
|
|
|
|
-webkit-backdrop-filter: blur(32px);
|
|
|
|
backdrop-filter: blur(32px);
|
|
|
|
background-color: var(--header);
|
2020-11-29 00:18:54 +09:00
|
|
|
//border-bottom: solid 1px var(--divider);
|
2020-11-07 12:30:16 +09:00
|
|
|
user-select: none;
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
> main {
|
|
|
|
min-width: 0;
|
|
|
|
|
|
|
|
> .content {
|
|
|
|
> * {
|
|
|
|
// ほんとは単に calc(100vh - #{$header-height}) と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
|
|
min-height: calc((var(--vh, 1vh) * 100) - #{$header-height});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .spacer {
|
|
|
|
height: 82px;
|
2020-10-17 23:49:17 +09:00
|
|
|
|
|
|
|
@media (min-width: ($widgets-hide-threshold + 1px)) {
|
|
|
|
display: none;
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-25 01:21:41 +09:00
|
|
|
> .side {
|
|
|
|
min-width: 370px;
|
|
|
|
max-width: 370px;
|
|
|
|
border-left: solid 1px var(--divider);
|
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
> .widgets {
|
|
|
|
padding: 0 var(--margin);
|
|
|
|
border-left: solid 1px var(--divider);
|
|
|
|
|
|
|
|
@media (max-width: $widgets-hide-threshold) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .widgetButton {
|
|
|
|
display: block;
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
bottom: 32px;
|
|
|
|
right: 32px;
|
|
|
|
width: 64px;
|
|
|
|
height: 64px;
|
|
|
|
border-radius: 100%;
|
|
|
|
box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12);
|
|
|
|
font-size: 22px;
|
|
|
|
background: var(--panel);
|
|
|
|
|
|
|
|
&.navHidden {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (min-width: ($widgets-hide-threshold + 1px)) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .buttons {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
bottom: 0;
|
2020-12-29 17:31:46 +09:00
|
|
|
padding: 16px;
|
2020-10-17 20:12:00 +09:00
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
2020-12-29 17:31:46 +09:00
|
|
|
-webkit-backdrop-filter: blur(32px);
|
|
|
|
backdrop-filter: blur(32px);
|
|
|
|
background-color: var(--header);
|
2020-10-17 20:12:00 +09:00
|
|
|
|
|
|
|
&:not(.navHidden) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .button {
|
|
|
|
position: relative;
|
2020-12-29 17:31:46 +09:00
|
|
|
flex: 1;
|
2020-10-17 20:12:00 +09:00
|
|
|
padding: 0;
|
|
|
|
margin: auto;
|
|
|
|
height: 64px;
|
2020-12-29 17:31:46 +09:00
|
|
|
border-radius: 8px;
|
2020-10-17 20:12:00 +09:00
|
|
|
background: var(--panel);
|
|
|
|
color: var(--fg);
|
|
|
|
|
2020-12-29 17:31:46 +09:00
|
|
|
&:not(:last-child) {
|
|
|
|
margin-right: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 400px) {
|
|
|
|
height: 60px;
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
&:hover {
|
|
|
|
background: var(--X2);
|
|
|
|
}
|
|
|
|
|
|
|
|
> i {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .tray-back {
|
|
|
|
z-index: 1001;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .tray {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
z-index: 1001;
|
|
|
|
// ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
|
|
height: calc(var(--vh, 1vh) * 100);
|
|
|
|
padding: var(--margin);
|
|
|
|
box-sizing: border-box;
|
|
|
|
overflow: auto;
|
|
|
|
background: var(--bg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
</style>
|