hippofish/packages/client/src/ui/deck/main-column.vue

79 lines
2.1 KiB
Vue
Raw Normal View History

2020-12-26 10:33:54 +01:00
<template>
<XColumn v-if="deckStore.state.alwaysShowMainColumn || $route.name !== 'index'" :column="column" :is-stacked="isStacked" @parent-focus="$event => emit('parent-focus', $event)">
2020-12-26 10:33:54 +01:00
<template #header>
2021-10-08 15:03:06 +02:00
<template v-if="pageInfo">
2021-10-14 16:14:14 +02:00
<i :class="pageInfo.icon"></i>
2021-10-08 15:03:06 +02:00
{{ pageInfo.title }}
</template>
2020-12-26 10:33:54 +01:00
</template>
2021-10-23 21:03:07 +02:00
<MkStickyContainer>
<template #header><MkHeader v-if="pageInfo && !pageInfo.hideHeader" :info="pageInfo"/></template>
<router-view v-slot="{ Component }">
<transition>
<keep-alive :include="['MkTimelinePage']">
2021-10-23 21:03:07 +02:00
<component :is="Component" :ref="changePage" @contextmenu.stop="onContextmenu"/>
</keep-alive>
</transition>
</router-view>
</MkStickyContainer>
2020-12-26 10:33:54 +01:00
</XColumn>
</template>
<script lang="ts" setup>
import { } from 'vue';
2020-12-26 10:33:54 +01:00
import XColumn from './column.vue';
import { deckStore, Column } from '@/ui/deck/deck-store';
2021-11-11 18:02:25 +01:00
import * as os from '@/os';
import * as symbols from '@/symbols';
import { i18n } from '@/i18n';
import { router } from '@/router';
2020-12-26 10:33:54 +01:00
defineProps<{
column: Column;
isStacked: boolean;
}>();
2020-12-26 10:33:54 +01:00
const emit = defineEmits<{
(ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void;
}>();
2020-12-29 14:00:02 +01:00
let pageInfo = $ref<Record<string, any> | null>(null);
2021-08-05 15:43:14 +02:00
function changePage(page) {
if (page == null) return;
if (page[symbols.PAGE_INFO]) {
pageInfo = page[symbols.PAGE_INFO];
2020-12-26 10:33:54 +01:00
}
}
/*
function back() {
history.back();
}
*/
function onContextmenu(ev: MouseEvent) {
if (!ev.target) return;
const isLink = (el: HTMLElement) => {
if (el.tagName === 'A') return true;
if (el.parentElement) {
return isLink(el.parentElement);
}
};
if (isLink(ev.target as HTMLElement)) return;
if (['INPUT', 'TEXTAREA', 'IMG', 'VIDEO', 'CANVAS'].includes((ev.target as HTMLElement).tagName) || (ev.target as HTMLElement).attributes['contenteditable']) return;
if (window.getSelection()?.toString() !== '') return;
const path = router.currentRoute.value.path;
os.contextMenu([{
type: 'label',
text: path,
}, {
icon: 'fas fa-window-maximize',
text: i18n.ts.openInWindow,
action: () => {
os.pageWindow(path);
}
}], ev);
}
2020-12-26 10:33:54 +01:00
</script>