misskey/src/client/ui/deck/main-column.vue

92 lines
2.0 KiB
Vue
Raw Normal View History

2020-12-26 18:33:54 +09:00
<template>
<XColumn v-if="deckStore.state.alwaysShowMainColumn || $route.name !== 'index'" :column="column" :is-stacked="isStacked">
<template #header>
2021-10-08 22:03:06 +09:00
<template v-if="pageInfo">
2021-10-14 23:14:14 +09:00
<i :class="pageInfo.icon"></i>
2021-10-08 22:03:06 +09:00
{{ pageInfo.title }}
</template>
2020-12-26 18:33:54 +09:00
</template>
2021-10-24 04:03:07 +09:00
<MkStickyContainer>
<template #header><MkHeader v-if="pageInfo && !pageInfo.hideHeader" :info="pageInfo"/></template>
<router-view v-slot="{ Component }">
<transition>
<keep-alive :include="['timeline']">
<component :is="Component" :ref="changePage" @contextmenu.stop="onContextmenu"/>
</keep-alive>
</transition>
</router-view>
</MkStickyContainer>
2020-12-26 18:33:54 +09:00
</XColumn>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import XColumn from './column.vue';
2021-03-23 17:30:14 +09:00
import XNotes from '@client/components/notes.vue';
import { deckStore } from '@client/ui/deck/deck-store';
import * as os from '@client/os';
2021-04-10 12:54:12 +09:00
import * as symbols from '@client/symbols';
2020-12-26 18:33:54 +09:00
export default defineComponent({
components: {
XColumn,
XNotes
},
props: {
column: {
type: Object,
required: true
},
isStacked: {
type: Boolean,
required: true
}
},
data() {
return {
deckStore,
pageInfo: null,
}
},
methods: {
changePage(page) {
if (page == null) return;
2021-04-10 12:54:12 +09:00
if (page[symbols.PAGE_INFO]) {
this.pageInfo = page[symbols.PAGE_INFO];
2020-12-26 18:33:54 +09:00
}
},
2020-12-29 22:00:02 +09:00
2021-08-05 22:43:14 +09:00
back() {
history.back();
},
2020-12-29 22:00:02 +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;
2021-04-29 12:31:47 +09:00
if (['INPUT', 'TEXTAREA', 'IMG', 'VIDEO', 'CANVAS'].includes(e.target.tagName) || e.target.attributes['contenteditable']) return;
2021-01-11 18:49:39 +09:00
if (window.getSelection().toString() !== '') return;
2020-12-29 22:00:02 +09:00
const path = this.$route.path;
os.contextMenu([{
type: 'label',
text: path,
}, {
icon: 'fas fa-window-maximize',
2020-12-29 22:00:02 +09:00
text: this.$ts.openInWindow,
action: () => {
os.pageWindow(path);
}
}], e);
},
2020-12-26 18:33:54 +09:00
}
});
</script>