2020-10-17 11:12:00 +00:00
|
|
|
<template>
|
2021-04-10 03:40:50 +00:00
|
|
|
<div class="mk-app" :class="{ wallpaper, isMobile }">
|
|
|
|
<div class="columns">
|
|
|
|
<div class="sidebar" ref="sidebar" v-if="!isMobile">
|
|
|
|
<XSidebar/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<main class="main _panel" @contextmenu.stop="onContextmenu">
|
|
|
|
<header v-if="$store.state.titlebar" class="header" @click="onHeaderClick">
|
|
|
|
<XHeader :info="pageInfo"/>
|
|
|
|
</header>
|
|
|
|
<div class="content _flat_">
|
2020-10-17 11:12:00 +00:00
|
|
|
<router-view v-slot="{ Component }">
|
2020-12-19 01:55:52 +00:00
|
|
|
<transition :name="$store.state.animation ? 'page' : ''" mode="out-in" @enter="onTransition">
|
2020-10-17 11:12:00 +00:00
|
|
|
<keep-alive :include="['timeline']">
|
|
|
|
<component :is="Component" :ref="changePage"/>
|
|
|
|
</keep-alive>
|
|
|
|
</transition>
|
|
|
|
</router-view>
|
|
|
|
</div>
|
|
|
|
</main>
|
2020-10-24 16:21:41 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
<div v-if="isDesktop" class="widgets" ref="widgets">
|
|
|
|
<XWidgets @mounted="attachSticky"/>
|
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
<div class="buttons" v-if="isMobile">
|
|
|
|
<button class="button nav _button" @click="showDrawerNav" ref="navButton"><Fa :icon="faBars"/><i v-if="navIndicated"><Fa :icon="faCircle"/></i></button>
|
2020-12-29 08:31:46 +00:00
|
|
|
<button class="button home _button" @click="$route.name === 'index' ? top() : $router.push('/')"><Fa :icon="faHome"/></button>
|
2020-12-19 01:55:52 +00: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 11:12:00 +00:00
|
|
|
<button class="button widget _button" @click="widgetsShowing = true"><Fa :icon="faLayerGroup"/></button>
|
2020-12-27 01:42:38 +00:00
|
|
|
<button class="button post _button" @click="post"><Fa :icon="faPencilAlt"/></button>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
<XDrawerSidebar ref="drawerNav" class="sidebar" v-if="isMobile"/>
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
<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-24 16:21:41 +00:00
|
|
|
<XCommon/>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-12-30 02:01:33 +00:00
|
|
|
import { defineComponent, defineAsyncComponent } from 'vue';
|
2020-12-27 01:42:38 +00:00
|
|
|
import { faLayerGroup, faBars, faHome, faCircle, faWindowMaximize, faColumns, faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
2020-10-17 11:12:00 +00:00
|
|
|
import { faBell } from '@fortawesome/free-regular-svg-icons';
|
2021-03-23 08:30:14 +00:00
|
|
|
import { instanceName } from '@client/config';
|
|
|
|
import { StickySidebar } from '@client/scripts/sticky-sidebar';
|
2021-04-10 03:40:50 +00:00
|
|
|
import XSidebar from './default.sidebar.vue';
|
|
|
|
import XDrawerSidebar from '@client/ui/_common_/sidebar.vue';
|
2020-10-24 16:21:41 +00:00
|
|
|
import XCommon from './_common_/common.vue';
|
2020-10-17 11:12:00 +00:00
|
|
|
import XHeader from './_common_/header.vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import * as os from '@client/os';
|
|
|
|
import { sidebarDef } from '@client/sidebar';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
const DESKTOP_THRESHOLD = 1100;
|
2021-04-10 03:40:50 +00:00
|
|
|
const MOBILE_THRESHOLD = 600;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-10-24 16:21:41 +00:00
|
|
|
XCommon,
|
2020-10-17 11:12:00 +00:00
|
|
|
XSidebar,
|
2021-04-10 03:40:50 +00:00
|
|
|
XDrawerSidebar,
|
2020-10-17 11:12:00 +00:00
|
|
|
XHeader,
|
|
|
|
XWidgets: defineAsyncComponent(() => import('./default.widgets.vue')),
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
pageInfo: null,
|
|
|
|
menuDef: sidebarDef,
|
2021-04-10 03:40:50 +00:00
|
|
|
isMobile: window.innerWidth <= MOBILE_THRESHOLD,
|
|
|
|
isDesktop: window.innerWidth >= DESKTOP_THRESHOLD,
|
2020-10-17 11:12:00 +00:00
|
|
|
widgetsShowing: false,
|
|
|
|
wallpaper: localStorage.getItem('wallpaper') != null,
|
2020-12-27 01:42:38 +00:00
|
|
|
faLayerGroup, faBars, faBell, faHome, faCircle, faPencilAlt,
|
2020-10-17 11:12:00 +00: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 01:55:52 +00:00
|
|
|
if (this.$store.state.widgets.length === 0) {
|
|
|
|
this.$store.set('widgets', [{
|
2020-10-17 11:12:00 +00:00
|
|
|
name: 'calendar',
|
|
|
|
id: 'a', place: 'right', data: {}
|
|
|
|
}, {
|
|
|
|
name: 'notifications',
|
|
|
|
id: 'b', place: 'right', data: {}
|
|
|
|
}, {
|
|
|
|
name: 'trends',
|
|
|
|
id: 'c', place: 'right', data: {}
|
|
|
|
}]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-04-10 03:40:50 +00:00
|
|
|
window.addEventListener('resize', () => {
|
|
|
|
this.isMobile = (window.innerWidth <= MOBILE_THRESHOLD);
|
|
|
|
this.isDesktop = (window.innerWidth >= DESKTOP_THRESHOLD);
|
|
|
|
}, { passive: true });
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
changePage(page) {
|
|
|
|
if (page == null) return;
|
|
|
|
if (page.INFO) {
|
|
|
|
this.pageInfo = page.INFO;
|
2020-12-30 02:01:33 +00:00
|
|
|
document.title = `${this.pageInfo.title} | ${instanceName}`;
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
attachSticky() {
|
|
|
|
const sticky = new StickySidebar(this.$refs.widgets, 16);
|
2020-10-17 11:12:00 +00:00
|
|
|
window.addEventListener('scroll', () => {
|
|
|
|
sticky.calc(window.scrollY);
|
|
|
|
}, { passive: true });
|
|
|
|
},
|
|
|
|
|
2020-12-27 01:42:38 +00:00
|
|
|
post() {
|
|
|
|
os.post();
|
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
top() {
|
|
|
|
window.scroll({ top: 0, behavior: 'smooth' });
|
|
|
|
},
|
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
showDrawerNav() {
|
|
|
|
this.$refs.drawerNav.show();
|
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
onTransition() {
|
|
|
|
if (window._scroll) window._scroll();
|
|
|
|
},
|
|
|
|
|
2020-11-07 03:30:16 +00:00
|
|
|
onHeaderClick() {
|
|
|
|
window.scroll({ top: 0, behavior: 'smooth' });
|
|
|
|
},
|
|
|
|
|
2020-10-25 00:26:19 +00:00
|
|
|
onContextmenu(e) {
|
2021-02-06 15:11:16 +00: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 12:18:35 +00:00
|
|
|
if (['INPUT', 'TEXTAREA'].includes(e.target.tagName) || e.target.attributes['contenteditable']) return;
|
2021-01-11 09:49:39 +00:00
|
|
|
if (window.getSelection().toString() !== '') return;
|
2020-11-03 01:06:19 +00:00
|
|
|
const path = this.$route.path;
|
2020-10-25 00:26:19 +00:00
|
|
|
os.contextMenu([{
|
|
|
|
type: 'label',
|
2020-11-03 01:06:19 +00:00
|
|
|
text: path,
|
2020-10-25 00:26:19 +00:00
|
|
|
}, {
|
|
|
|
icon: faWindowMaximize,
|
2020-12-26 01:47:36 +00:00
|
|
|
text: this.$ts.openInWindow,
|
2020-10-25 00:26:19 +00:00
|
|
|
action: () => {
|
2020-11-03 01:06:19 +00:00
|
|
|
os.pageWindow(path);
|
2020-10-25 00:26:19 +00:00
|
|
|
}
|
|
|
|
}], e);
|
|
|
|
},
|
2020-10-17 11:12:00 +00: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 {
|
2021-04-10 03:40:50 +00:00
|
|
|
$header-height: 50px;
|
|
|
|
$ui-font-size: 1em;
|
|
|
|
$widgets-hide-threshold: 1200px;
|
|
|
|
$nav-icon-only-width: 78px; // TODO: どこかに集約したい
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
// ほんとは単に 100vh と書きたいところだが... https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
|
|
|
|
min-height: calc(var(--vh, 1vh) * 100);
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
2020-11-28 04:30:09 +00:00
|
|
|
&.wallpaper {
|
|
|
|
background: var(--wallpaperOverlay);
|
|
|
|
//backdrop-filter: blur(4px);
|
|
|
|
}
|
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
&.isMobile {
|
|
|
|
> .columns {
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
2020-12-29 02:47:36 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
> .main {
|
|
|
|
margin: 0;
|
|
|
|
border: none;
|
|
|
|
width: 100%;
|
|
|
|
border-radius: 0;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
> .header {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
2021-04-10 03:40:50 +00:00
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
> .columns {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
max-width: 100%;
|
|
|
|
margin: 32px 0;
|
|
|
|
|
|
|
|
> .main {
|
|
|
|
width: 750px;
|
|
|
|
margin: 0 16px 0 0;
|
|
|
|
background: var(--bg);
|
|
|
|
--margin: 12px;
|
|
|
|
|
|
|
|
> .header {
|
|
|
|
position: sticky;
|
|
|
|
z-index: 1000;
|
|
|
|
top: 0;
|
|
|
|
height: $header-height;
|
|
|
|
line-height: $header-height;
|
|
|
|
-webkit-backdrop-filter: blur(32px);
|
|
|
|
backdrop-filter: blur(32px);
|
|
|
|
background-color: var(--header);
|
|
|
|
border-bottom: solid 0.5px var(--divider);
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
> .content {
|
2021-04-10 03:40:50 +00:00
|
|
|
background: var(--bg);
|
|
|
|
--stickyTop: #{$header-height};
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
@media (max-width: 850px) {
|
|
|
|
padding-top: $header-height;
|
2020-10-17 14:49:17 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
> .header {
|
|
|
|
position: fixed;
|
|
|
|
width: calc(100% - #{$nav-icon-only-width});
|
2020-10-17 14:49:17 +00:00
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-24 16:21:41 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
> .widgets {
|
|
|
|
//--panelShadow: none;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
@media (max-width: $widgets-hide-threshold) {
|
|
|
|
display: none;
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
@media (max-width: 850px) {
|
|
|
|
margin: 0;
|
|
|
|
|
|
|
|
> .sidebar {
|
|
|
|
border-right: solid 0.5px var(--divider);
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
> .main {
|
|
|
|
margin: 0;
|
|
|
|
border-radius: 0;
|
|
|
|
box-shadow: none;
|
|
|
|
width: 100%;
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .buttons {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
bottom: 0;
|
2020-12-29 08:31:46 +00:00
|
|
|
padding: 16px;
|
2020-10-17 11:12:00 +00:00
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
2020-12-29 08:31:46 +00:00
|
|
|
-webkit-backdrop-filter: blur(32px);
|
|
|
|
backdrop-filter: blur(32px);
|
|
|
|
background-color: var(--header);
|
2021-04-10 03:40:50 +00:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
> .button {
|
|
|
|
position: relative;
|
2020-12-29 08:31:46 +00:00
|
|
|
flex: 1;
|
2020-10-17 11:12:00 +00:00
|
|
|
padding: 0;
|
|
|
|
margin: auto;
|
|
|
|
height: 64px;
|
2020-12-29 08:31:46 +00:00
|
|
|
border-radius: 8px;
|
2020-10-17 11:12:00 +00:00
|
|
|
background: var(--panel);
|
|
|
|
color: var(--fg);
|
|
|
|
|
2020-12-29 08:31:46 +00:00
|
|
|
&:not(:last-child) {
|
|
|
|
margin-right: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 400px) {
|
|
|
|
height: 60px;
|
|
|
|
|
|
|
|
&:not(:last-child) {
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 11:12:00 +00: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>
|