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