2020-12-26 18:33:54 +09:00
|
|
|
<template>
|
2023-05-20 10:12:18 +09:00
|
|
|
<XColumn v-if="deckStore.state.alwaysShowMainColumn || mainRouter.currentRoute.value.name !== 'index'" :column="column" :isStacked="isStacked">
|
2020-12-26 18:33:54 +09:00
|
|
|
<template #header>
|
2022-06-20 17:38:49 +09:00
|
|
|
<template v-if="pageMetadata?.value">
|
|
|
|
<i :class="pageMetadata?.value.icon"></i>
|
|
|
|
{{ pageMetadata?.value.title }}
|
2021-10-08 22:03:06 +09:00
|
|
|
</template>
|
2020-12-26 18:33:54 +09:00
|
|
|
</template>
|
|
|
|
|
2023-07-08 15:30:36 +09:00
|
|
|
<div ref="contents">
|
|
|
|
<RouterView @contextmenu.stop="onContextmenu"/>
|
|
|
|
</div>
|
2020-12-26 18:33:54 +09:00
|
|
|
</XColumn>
|
|
|
|
</template>
|
|
|
|
|
2022-03-21 03:11:14 +09:00
|
|
|
<script lang="ts" setup>
|
2023-07-08 15:30:36 +09:00
|
|
|
import { ComputedRef, provide, shallowRef } from 'vue';
|
2020-12-26 18:33:54 +09:00
|
|
|
import XColumn from './column.vue';
|
2022-03-21 03:11:14 +09:00
|
|
|
import { deckStore, Column } from '@/ui/deck/deck-store';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2022-03-21 03:11:14 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { mainRouter } from '@/router';
|
2023-02-16 23:09:41 +09:00
|
|
|
import { PageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata';
|
2023-07-08 15:30:36 +09:00
|
|
|
import { useScrollPositionManager } from '@/nirax';
|
|
|
|
import { getScrollContainer } from '@/scripts/scroll';
|
2020-12-26 18:33:54 +09:00
|
|
|
|
2022-03-21 03:11:14 +09:00
|
|
|
defineProps<{
|
|
|
|
column: Column;
|
|
|
|
isStacked: boolean;
|
|
|
|
}>();
|
2020-12-26 18:33:54 +09:00
|
|
|
|
2023-07-08 15:30:36 +09:00
|
|
|
const contents = shallowRef<HTMLElement>();
|
2022-06-20 17:38:49 +09:00
|
|
|
let pageMetadata = $ref<null | ComputedRef<PageMetadata>>();
|
|
|
|
|
|
|
|
provide('router', mainRouter);
|
|
|
|
provideMetadataReceiver((info) => {
|
|
|
|
pageMetadata = info;
|
|
|
|
});
|
2021-08-05 22:43:14 +09:00
|
|
|
|
2022-03-21 03:11:14 +09: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 23:33:55 +09:00
|
|
|
const path = mainRouter.currentRoute.value.path;
|
2022-03-21 03:11:14 +09:00
|
|
|
os.contextMenu([{
|
|
|
|
type: 'label',
|
|
|
|
text: path,
|
|
|
|
}, {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-window-maximize',
|
2022-03-21 03:11:14 +09:00
|
|
|
text: i18n.ts.openInWindow,
|
|
|
|
action: () => {
|
|
|
|
os.pageWindow(path);
|
2022-06-20 17:38:49 +09:00
|
|
|
},
|
2022-03-21 03:11:14 +09:00
|
|
|
}], ev);
|
|
|
|
}
|
2023-07-08 15:30:36 +09:00
|
|
|
|
|
|
|
useScrollPositionManager(() => getScrollContainer(contents.value), mainRouter);
|
2020-12-26 18:33:54 +09:00
|
|
|
</script>
|