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

69 lines
1.9 KiB
Vue
Raw Normal View History

2020-12-26 09:33:54 +00:00
<template>
<XColumn v-if="deckStore.state.alwaysShowMainColumn || mainRouter.currentRoute.value.name !== 'index'" :column="column" :is-stacked="isStacked" @parent-focus="$event => emit('parent-focus', $event)">
2020-12-26 09:33:54 +00:00
<template #header>
<template v-if="pageMetadata?.value">
<i :class="pageMetadata?.value.icon"></i>
{{ pageMetadata?.value.title }}
2021-10-08 13:03:06 +00:00
</template>
2020-12-26 09:33:54 +00:00
</template>
<RouterView @contextmenu.stop="onContextmenu"/>
2020-12-26 09:33:54 +00:00
</XColumn>
</template>
<script lang="ts" setup>
import { ComputedRef, provide } from 'vue';
2020-12-26 09:33:54 +00:00
import XColumn from './column.vue';
import { deckStore, Column } from '@/ui/deck/deck-store';
2021-11-11 17:02:25 +00:00
import * as os from '@/os';
import { i18n } from '@/i18n';
import { mainRouter } from '@/router';
import { PageMetadata, provideMetadataReceiver, setPageMetadata } from '@/scripts/page-metadata';
2020-12-26 09:33:54 +00:00
defineProps<{
column: Column;
isStacked: boolean;
}>();
2020-12-26 09:33:54 +00:00
const emit = defineEmits<{
(ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void;
}>();
2020-12-29 13:00:02 +00:00
let pageMetadata = $ref<null | ComputedRef<PageMetadata>>();
provide('router', mainRouter);
provideMetadataReceiver((info) => {
pageMetadata = info;
});
2021-08-05 13:43:14 +00: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;
2022-07-04 14:33:55 +00:00
const path = mainRouter.currentRoute.value.path;
os.contextMenu([{
type: 'label',
text: path,
}, {
icon: 'ti ti-window-maximize',
text: i18n.ts.openInWindow,
action: () => {
os.pageWindow(path);
},
}], ev);
}
2020-12-26 09:33:54 +00:00
</script>