yumechi-no-kuni/packages/client/src/ui/classic.side.vue

159 lines
3.3 KiB
Vue
Raw Normal View History

<template>
2021-11-19 04:36:12 -06:00
<div v-if="component" class="qvzfzxam _narrow_">
<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>
2021-10-08 08:03:06 -05:00
<span class="title">{{ pageInfo.title }}</span>
<button class="_button" @click="close()"><i class="fas fa-times"></i></button>
</header>
2021-10-08 22:33:08 -05:00
<MkHeader class="pageHeader" :info="pageInfo"/>
<component :is="component" v-bind="props" :ref="changePage"/>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
2021-11-11 11:02:25 -06:00
import * as os from '@/os';
import copyToClipboard from '@/scripts/copy-to-clipboard';
import { resolve } from '@/router';
import { url } from '@/config';
import * as symbols from '@/symbols';
export default defineComponent({
provide() {
return {
navHook: (path) => {
this.navigate(path);
}
};
},
data() {
return {
path: null,
component: null,
props: {},
pageInfo: null,
history: [],
};
},
computed: {
url(): string {
return url + this.path;
}
},
methods: {
changePage(page) {
if (page == null) return;
2021-04-09 22:54:12 -05:00
if (page[symbols.PAGE_INFO]) {
this.pageInfo = page[symbols.PAGE_INFO];
}
},
navigate(path, record = true) {
if (record && this.path) this.history.push(this.path);
this.path = path;
const { component, props } = resolve(path);
this.component = component;
this.props = props;
},
back() {
this.navigate(this.history.pop(), false);
},
close() {
this.path = null;
this.component = null;
this.props = {};
},
2022-01-18 06:35:57 -06:00
onContextmenu(ev: MouseEvent) {
os.contextMenu([{
type: 'label',
text: this.path,
}, {
icon: 'fas fa-expand-alt',
2020-12-25 19:47:36 -06:00
text: this.$ts.showInPage,
action: () => {
this.$router.push(this.path);
this.close();
}
}, {
icon: 'fas fa-window-maximize',
2020-12-25 19:47:36 -06:00
text: this.$ts.openInWindow,
action: () => {
os.pageWindow(this.path);
this.close();
}
}, null, {
icon: 'fas fa-external-link-alt',
2020-12-25 19:47:36 -06:00
text: this.$ts.openInNewTab,
action: () => {
window.open(this.url, '_blank');
this.close();
}
}, {
icon: 'fas fa-link',
2020-12-25 19:47:36 -06:00
text: this.$ts.copyLink,
action: () => {
copyToClipboard(this.url);
}
2022-01-18 06:35:57 -06:00
}], ev);
}
}
});
</script>
<style lang="scss" scoped>
.qvzfzxam {
$header-height: 58px; // TODO: どこかに集約したい
--root-margin: 16px;
--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));
background-color: var(--header);
> ._button {
height: $header-height;
width: $header-height;
&:hover {
color: var(--fgHighlighted);
}
}
> .title {
flex: 1;
position: relative;
}
}
}
}
</style>