2020-10-17 05:12:00 -06:00
|
|
|
<template>
|
2022-06-20 02:38:49 -06:00
|
|
|
<XWindow
|
|
|
|
ref="windowEl"
|
2020-12-29 21:07:16 -07:00
|
|
|
:initial-width="500"
|
2020-10-24 10:21:41 -06:00
|
|
|
:initial-height="500"
|
|
|
|
:can-resize="true"
|
2021-10-08 07:03:06 -06:00
|
|
|
:close-button="true"
|
2022-06-20 02:38:49 -06:00
|
|
|
:buttons-left="buttonsLeft"
|
|
|
|
:buttons-right="buttonsRight"
|
2020-10-24 10:21:41 -06:00
|
|
|
:contextmenu="contextmenu"
|
|
|
|
@closed="$emit('closed')"
|
|
|
|
>
|
2020-10-17 05:12:00 -06:00
|
|
|
<template #header>
|
2022-06-20 02:38:49 -06:00
|
|
|
<template v-if="pageMetadata?.value">
|
|
|
|
<i v-if="pageMetadata.value.icon" class="icon" :class="pageMetadata.value.icon" style="margin-right: 0.5em;"></i>
|
|
|
|
<span>{{ pageMetadata.value.title }}</span>
|
2021-10-08 07:03:06 -06:00
|
|
|
</template>
|
|
|
|
</template>
|
2021-12-23 20:34:24 -07:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
<div class="yrolvcoq" :style="{ background: pageMetadata?.value?.bg }">
|
|
|
|
<RouterView :router="router"/>
|
2020-10-17 05:12:00 -06:00
|
|
|
</div>
|
|
|
|
</XWindow>
|
|
|
|
</template>
|
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { ComputedRef, inject, provide } from 'vue';
|
2022-08-30 09:24:33 -06:00
|
|
|
import RouterView from '@/components/global/RouterView.vue';
|
2022-09-06 03:21:49 -06:00
|
|
|
import XWindow from '@/components/MkWindow.vue';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { popout as _popout } from '@/scripts/popout';
|
2021-11-11 10:02:25 -07:00
|
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
|
|
|
import { url } from '@/config';
|
2021-12-23 20:34:24 -07:00
|
|
|
import * as os from '@/os';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { mainRouter, routes } from '@/router';
|
|
|
|
import { Router } from '@/nirax';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { PageMetadata, provideMetadataReceiver, setPageMetadata } from '@/scripts/page-metadata';
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
initialPath: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
defineEmits<{
|
|
|
|
(ev: 'closed'): void;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const router = new Router(routes, props.initialPath);
|
|
|
|
|
|
|
|
let pageMetadata = $ref<null | ComputedRef<PageMetadata>>();
|
|
|
|
let windowEl = $ref<InstanceType<typeof XWindow>>();
|
2022-07-01 21:12:10 -06:00
|
|
|
const history = $ref<{ path: string; key: any; }[]>([{
|
|
|
|
path: router.getCurrentPath(),
|
|
|
|
key: router.getCurrentKey(),
|
|
|
|
}]);
|
2022-06-20 02:38:49 -06:00
|
|
|
const buttonsLeft = $computed(() => {
|
|
|
|
const buttons = [];
|
|
|
|
|
|
|
|
if (history.length > 1) {
|
|
|
|
buttons.push({
|
2022-11-06 19:49:47 -07:00
|
|
|
icon: 'ph--left-bold ph-lg',
|
2022-06-20 02:38:49 -06:00
|
|
|
onClick: back,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return buttons;
|
|
|
|
});
|
|
|
|
const buttonsRight = $computed(() => {
|
|
|
|
const buttons = [{
|
2022-11-06 19:49:47 -07:00
|
|
|
icon: 'ph-arrows-out-simple-bold ph-lg',
|
2022-06-20 02:38:49 -06:00
|
|
|
title: i18n.ts.showInPage,
|
|
|
|
onClick: expand,
|
|
|
|
}];
|
|
|
|
|
|
|
|
return buttons;
|
|
|
|
});
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
router.addListener('push', ctx => {
|
2022-07-01 21:12:10 -06:00
|
|
|
history.push({ path: ctx.path, key: ctx.key });
|
2022-06-20 02:38:49 -06:00
|
|
|
});
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
provide('router', router);
|
|
|
|
provideMetadataReceiver((info) => {
|
|
|
|
pageMetadata = info;
|
|
|
|
});
|
|
|
|
provide('shouldOmitHeaderTitle', true);
|
|
|
|
provide('shouldHeaderThin', true);
|
|
|
|
|
|
|
|
const contextmenu = $computed(() => ([{
|
2022-11-06 19:49:47 -07:00
|
|
|
icon: 'ph-arrows-out-simple-bold ph-lg',
|
2022-06-20 02:38:49 -06:00
|
|
|
text: i18n.ts.showInPage,
|
|
|
|
action: expand,
|
|
|
|
}, {
|
2022-11-06 19:49:47 -07:00
|
|
|
icon: 'ph-arrow-square-out-bold ph-lg',
|
2022-06-20 02:38:49 -06:00
|
|
|
text: i18n.ts.popout,
|
|
|
|
action: popout,
|
|
|
|
}, {
|
2022-11-06 19:49:47 -07:00
|
|
|
icon: 'ph-arrow-square-out-bold ph-lg',
|
2022-06-20 02:38:49 -06:00
|
|
|
text: i18n.ts.openInNewTab,
|
|
|
|
action: () => {
|
|
|
|
window.open(url + router.getCurrentPath(), '_blank');
|
|
|
|
windowEl.close();
|
2020-10-28 07:21:53 -06:00
|
|
|
},
|
2022-06-20 02:38:49 -06:00
|
|
|
}, {
|
2022-11-06 19:49:47 -07:00
|
|
|
icon: 'ph-link-simple-bold ph-lg',
|
2022-06-20 02:38:49 -06:00
|
|
|
text: i18n.ts.copyLink,
|
|
|
|
action: () => {
|
|
|
|
copyToClipboard(url + router.getCurrentPath());
|
2020-10-24 10:21:41 -06:00
|
|
|
},
|
2022-06-20 02:38:49 -06:00
|
|
|
}]));
|
2020-10-24 10:21:41 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function menu(ev) {
|
|
|
|
os.popupMenu(contextmenu, ev.currentTarget ?? ev.target);
|
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function back() {
|
|
|
|
history.pop();
|
2022-07-20 04:59:27 -06:00
|
|
|
router.replace(history[history.length - 1].path, history[history.length - 1].key);
|
2022-06-20 02:38:49 -06:00
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function close() {
|
|
|
|
windowEl.close();
|
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function expand() {
|
2022-07-16 14:12:22 -06:00
|
|
|
mainRouter.push(router.getCurrentPath(), 'forcePage');
|
2022-06-20 02:38:49 -06:00
|
|
|
windowEl.close();
|
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function popout() {
|
|
|
|
_popout(router.getCurrentPath(), windowEl.$el);
|
|
|
|
windowEl.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
close,
|
2020-10-17 05:12:00 -06:00
|
|
|
});
|
|
|
|
</script>
|
2020-10-19 04:29:04 -06:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.yrolvcoq {
|
2021-04-09 21:40:50 -06:00
|
|
|
min-height: 100%;
|
2022-07-01 23:00:37 -06:00
|
|
|
background: var(--bg);
|
2020-10-19 04:29:04 -06:00
|
|
|
}
|
|
|
|
</style>
|