2021-04-11 14:09:35 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkModal ref="modal" @click="$emit('click')" @closed="$emit('closed')">
|
|
|
|
<div
|
|
|
|
ref="rootEl"
|
|
|
|
class="hrmcaedk _narrow_"
|
|
|
|
:style="{
|
|
|
|
width: `${width}px`,
|
|
|
|
height: height ? `min(${height}px, 100%)` : '100%',
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<div class="header" @contextmenu="onContextmenu">
|
|
|
|
<button
|
|
|
|
v-if="history.length > 0"
|
|
|
|
v-tooltip="i18n.ts.goBack"
|
|
|
|
class="_button"
|
|
|
|
@click="back()"
|
|
|
|
>
|
2023-10-17 03:57:20 +02:00
|
|
|
<i :class="icon('ph-caret-left')"></i>
|
2023-04-08 02:01:42 +02:00
|
|
|
</button>
|
|
|
|
<span v-else style="display: inline-block; width: 20px"></span>
|
|
|
|
<span v-if="pageMetadata?.value" class="title">
|
|
|
|
<i
|
|
|
|
v-if="pageMetadata?.value.icon"
|
|
|
|
class="icon"
|
2023-10-17 03:57:20 +02:00
|
|
|
:class="icon(pageMetadata?.value.icon)"
|
2023-04-08 02:01:42 +02:00
|
|
|
></i>
|
|
|
|
<span>{{ pageMetadata?.value.title }}</span>
|
|
|
|
</span>
|
2023-07-14 01:53:53 +02:00
|
|
|
<button
|
|
|
|
class="_button"
|
2024-04-03 06:36:09 +02:00
|
|
|
:aria-label="i18n.ts.close"
|
2024-04-12 05:31:11 +02:00
|
|
|
@click="modal!.close()"
|
2023-07-14 01:53:53 +02:00
|
|
|
>
|
2023-10-17 03:57:20 +02:00
|
|
|
<i :class="icon('ph-x')"></i>
|
2023-04-08 02:01:42 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="body">
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header
|
|
|
|
><MkPageHeader
|
|
|
|
v-if="
|
|
|
|
pageMetadata?.value &&
|
|
|
|
!pageMetadata?.value.hideHeader
|
|
|
|
"
|
|
|
|
:info="pageMetadata?.value"
|
|
|
|
/></template>
|
|
|
|
<RouterView :router="router" />
|
|
|
|
</MkStickyContainer>
|
|
|
|
</div>
|
2021-04-11 14:09:35 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
</MkModal>
|
2021-04-11 14:09:35 +02:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<script lang="ts" setup>
|
2023-09-02 01:27:33 +02:00
|
|
|
import type { ComputedRef } from "vue";
|
|
|
|
import { computed, provide, ref } from "vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import MkModal from "@/components/MkModal.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 { i18n } from "@/i18n";
|
2023-09-02 01:27:33 +02:00
|
|
|
import type { PageMetadata } from "@/scripts/page-metadata";
|
|
|
|
import { provideMetadataReceiver } from "@/scripts/page-metadata";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { Router } from "@/nirax";
|
2023-10-17 03:57:20 +02:00
|
|
|
import icon from "@/scripts/icon";
|
2024-04-12 05:31:11 +02:00
|
|
|
import type { MenuItem } from "@/types/menu";
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
initialPath: string;
|
|
|
|
}>();
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "closed"): void;
|
|
|
|
(ev: "click"): void;
|
2022-06-20 10:38:49 +02:00
|
|
|
}>();
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const router = new Router(routes, props.initialPath);
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
router.addListener("push", (ctx) => {});
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2023-09-02 01:27:33 +02:00
|
|
|
const pageMetadata = ref<null | ComputedRef<PageMetadata>>();
|
|
|
|
const rootEl = ref();
|
2024-04-12 05:31:11 +02:00
|
|
|
const modal = ref<InstanceType<typeof MkModal> | null>(null);
|
2023-09-02 01:27:33 +02:00
|
|
|
const path = ref(props.initialPath);
|
|
|
|
const width = ref(860);
|
|
|
|
const height = ref(660);
|
2024-04-12 05:31:11 +02:00
|
|
|
const history: string[] = [];
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
provide("router", router);
|
2022-06-20 10:38:49 +02:00
|
|
|
provideMetadataReceiver((info) => {
|
2023-08-12 02:44:46 +02:00
|
|
|
pageMetadata.value = info;
|
2022-06-20 10:38:49 +02:00
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
provide("shouldOmitHeaderTitle", true);
|
|
|
|
provide("shouldHeaderThin", true);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-08-12 02:44:46 +02:00
|
|
|
const pageUrl = computed(() => url + path.value);
|
2024-04-12 05:31:11 +02:00
|
|
|
const contextmenu = computed((): MenuItem[] => {
|
2023-04-08 02:01:42 +02:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
type: "label",
|
2023-08-12 02:44:46 +02:00
|
|
|
text: path.value,
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-arrows-out-simple")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
text: i18n.ts.showInPage,
|
|
|
|
action: expand,
|
|
|
|
},
|
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-arrow-square-out")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
text: i18n.ts.popout,
|
|
|
|
action: popout,
|
|
|
|
},
|
|
|
|
null,
|
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-arrow-square-out")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
text: i18n.ts.openInNewTab,
|
|
|
|
action: () => {
|
2023-08-12 02:44:46 +02:00
|
|
|
window.open(pageUrl.value, "_blank");
|
2024-04-12 05:31:11 +02:00
|
|
|
modal.value!.close();
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
2021-04-11 14:09:35 +02:00
|
|
|
},
|
2023-04-08 02:01:42 +02:00
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-link-simple")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
text: i18n.ts.copyLink,
|
|
|
|
action: () => {
|
2023-08-12 02:44:46 +02:00
|
|
|
copyToClipboard(pageUrl.value);
|
2024-04-27 14:45:00 +02:00
|
|
|
os.success();
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
2021-04-11 14:09:35 +02:00
|
|
|
},
|
2023-04-08 02:01:42 +02:00
|
|
|
];
|
2022-06-20 10:38:49 +02:00
|
|
|
});
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2024-04-12 05:31:11 +02:00
|
|
|
function navigate(path: string, record = true) {
|
2022-06-20 10:38:49 +02:00
|
|
|
if (record) history.push(router.getCurrentPath());
|
|
|
|
router.push(path);
|
|
|
|
}
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function back() {
|
2024-04-12 05:31:11 +02:00
|
|
|
const backTo = history.pop();
|
|
|
|
if (backTo) {
|
|
|
|
navigate(backTo, false);
|
|
|
|
}
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
2021-04-23 07:59:21 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function expand() {
|
2023-08-12 02:44:46 +02:00
|
|
|
mainRouter.push(path.value);
|
2024-04-12 05:31:11 +02:00
|
|
|
modal.value!.close();
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function popout() {
|
2023-08-12 02:44:46 +02:00
|
|
|
_popout(path.value, rootEl.value);
|
2024-04-12 05:31:11 +02:00
|
|
|
modal.value!.close();
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onContextmenu(ev: MouseEvent) {
|
2023-08-12 02:44:46 +02:00
|
|
|
os.contextMenu(contextmenu.value, ev);
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
2021-04-11 14:09:35 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.hrmcaedk {
|
|
|
|
overflow: hidden;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
contain: content;
|
2022-06-26 12:41:21 +02:00
|
|
|
border-radius: var(--radius);
|
2023-04-30 00:30:14 +02:00
|
|
|
margin: auto;
|
2021-04-11 14:09:35 +02:00
|
|
|
|
|
|
|
--root-margin: 24px;
|
|
|
|
|
|
|
|
@media (max-width: 500px) {
|
|
|
|
--root-margin: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .header {
|
2021-04-13 18:41:49 +02:00
|
|
|
$height: 52px;
|
2021-04-11 14:09:35 +02:00
|
|
|
$height-narrow: 42px;
|
|
|
|
display: flex;
|
|
|
|
flex-shrink: 0;
|
2021-10-08 17:46:52 +02:00
|
|
|
height: $height;
|
|
|
|
line-height: $height;
|
|
|
|
font-weight: bold;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2022-06-26 12:41:21 +02:00
|
|
|
background: var(--windowHeader);
|
|
|
|
-webkit-backdrop-filter: var(--blur, blur(15px));
|
|
|
|
backdrop-filter: var(--blur, blur(15px));
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2021-10-08 17:46:52 +02:00
|
|
|
> button {
|
2021-08-05 15:43:14 +02:00
|
|
|
height: $height;
|
2021-10-08 17:46:52 +02:00
|
|
|
width: $height;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--fgHighlighted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 500px) {
|
|
|
|
height: $height-narrow;
|
|
|
|
line-height: $height-narrow;
|
|
|
|
padding-left: 16px;
|
2021-04-11 14:09:35 +02:00
|
|
|
|
2021-10-08 17:46:52 +02:00
|
|
|
> button {
|
2021-08-05 15:43:14 +02:00
|
|
|
height: $height-narrow;
|
2021-10-08 17:46:52 +02:00
|
|
|
width: $height-narrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .title {
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
margin-right: 0.5em;
|
2021-04-11 14:09:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
overflow: auto;
|
|
|
|
background: var(--bg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|