2020-10-24 11:21:41 -05:00
|
|
|
<template>
|
2021-11-19 04:36:12 -06:00
|
|
|
<div v-if="component" class="qvzfzxam _narrow_">
|
2020-10-24 11:21:41 -05:00
|
|
|
<div class="container">
|
|
|
|
<header class="header" @contextmenu.prevent.stop="onContextmenu">
|
2021-11-19 04:36:12 -06:00
|
|
|
<button v-if="history.length > 0" class="_button" @click="back()"><i class="fas fa-chevron-left"></i></button>
|
|
|
|
<button v-else class="_button" style="pointer-events: none;"><!-- マージンのバランスを取るためのダミー --></button>
|
2022-02-01 08:48:19 -06:00
|
|
|
<span class="title" v-text="pageInfo?.title" />
|
2021-04-20 09:22:59 -05:00
|
|
|
<button class="_button" @click="close()"><i class="fas fa-times"></i></button>
|
2020-10-24 11:21:41 -05:00
|
|
|
</header>
|
2021-10-08 22:33:08 -05:00
|
|
|
<MkHeader class="pageHeader" :info="pageInfo"/>
|
2020-10-24 11:21:41 -05:00
|
|
|
<component :is="component" v-bind="props" :ref="changePage"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-02-01 08:48:19 -06:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { provide } from 'vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
|
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
2022-02-01 08:48:19 -06:00
|
|
|
import { resolve, router } from '@/router';
|
|
|
|
import { url as root } from '@/config';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as symbols from '@/symbols';
|
2022-02-01 08:48:19 -06:00
|
|
|
import { i18n } from '@/i18n';
|
2020-10-24 11:21:41 -05:00
|
|
|
|
2022-02-01 08:48:19 -06:00
|
|
|
provide('navHook', navigate);
|
2020-11-02 19:06:19 -06:00
|
|
|
|
2022-02-01 08:48:19 -06:00
|
|
|
let path: string | null = $ref(null);
|
|
|
|
let component: ReturnType<typeof resolve>['component'] | null = $ref(null);
|
|
|
|
let props: any | null = $ref(null);
|
|
|
|
let pageInfo: any | null = $ref(null);
|
|
|
|
let history: string[] = $ref([]);
|
|
|
|
|
|
|
|
let url = $computed(() => `${root}${path}`);
|
|
|
|
|
|
|
|
function changePage(page) {
|
|
|
|
if (page == null) return;
|
|
|
|
if (page[symbols.PAGE_INFO]) {
|
|
|
|
pageInfo = page[symbols.PAGE_INFO];
|
2020-10-24 11:21:41 -05:00
|
|
|
}
|
2022-02-01 08:48:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function navigate(_path: string, record = true) {
|
|
|
|
if (record && path) history.push($$(path).value);
|
|
|
|
path = _path;
|
|
|
|
const resolved = resolve(path);
|
|
|
|
component = resolved.component;
|
|
|
|
props = resolved.props;
|
|
|
|
}
|
|
|
|
|
|
|
|
function back() {
|
|
|
|
const prev = history.pop();
|
|
|
|
if (prev) navigate(prev, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
path = null;
|
|
|
|
component = null;
|
|
|
|
props = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
function onContextmenu(ev: MouseEvent) {
|
|
|
|
os.contextMenu([{
|
|
|
|
type: 'label',
|
|
|
|
text: path || '',
|
|
|
|
}, {
|
|
|
|
icon: 'fas fa-expand-alt',
|
|
|
|
text: i18n.ts.showInPage,
|
|
|
|
action: () => {
|
|
|
|
if (path) router.push(path);
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
icon: 'fas fa-window-maximize',
|
|
|
|
text: i18n.ts.openInWindow,
|
|
|
|
action: () => {
|
|
|
|
if (path) os.pageWindow(path);
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}, null, {
|
|
|
|
icon: 'fas fa-external-link-alt',
|
|
|
|
text: i18n.ts.openInNewTab,
|
|
|
|
action: () => {
|
|
|
|
window.open(url, '_blank');
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
icon: 'fas fa-link',
|
|
|
|
text: i18n.ts.copyLink,
|
|
|
|
action: () => {
|
|
|
|
copyToClipboard(url);
|
|
|
|
}
|
|
|
|
}], ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
navigate,
|
|
|
|
back,
|
|
|
|
close,
|
2020-10-24 11:21:41 -05:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.qvzfzxam {
|
|
|
|
$header-height: 58px; // TODO: どこかに集約したい
|
|
|
|
|
2021-04-09 22:40:50 -05:00
|
|
|
--root-margin: 16px;
|
2020-10-24 11:21:41 -05:00
|
|
|
--margin: var(--marginHalf);
|
|
|
|
|
|
|
|
> .container {
|
|
|
|
position: fixed;
|
|
|
|
width: 370px;
|
|
|
|
height: 100vh;
|
|
|
|
overflow: auto;
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
> .header {
|
|
|
|
display: flex;
|
|
|
|
position: sticky;
|
|
|
|
z-index: 1000;
|
|
|
|
top: 0;
|
|
|
|
height: $header-height;
|
|
|
|
width: 100%;
|
|
|
|
line-height: $header-height;
|
|
|
|
text-align: center;
|
|
|
|
font-weight: bold;
|
|
|
|
//background-color: var(--panel);
|
2021-08-11 08:34:45 -05:00
|
|
|
-webkit-backdrop-filter: var(--blur, blur(32px));
|
|
|
|
backdrop-filter: var(--blur, blur(32px));
|
2020-10-24 11:21:41 -05:00
|
|
|
background-color: var(--header);
|
|
|
|
|
|
|
|
> ._button {
|
|
|
|
height: $header-height;
|
|
|
|
width: $header-height;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--fgHighlighted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .title {
|
|
|
|
flex: 1;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|