2020-10-17 11:12:00 +00:00
|
|
|
<template>
|
2021-02-14 13:26:07 +00:00
|
|
|
<div class="fdidabkb" :class="{ center }" :style="`--height:${height};`">
|
2020-12-19 01:55:52 +00:00
|
|
|
<transition :name="$store.state.animation ? 'header' : ''" mode="out-in" appear>
|
2021-04-10 05:37:29 +00:00
|
|
|
<button class="_button back" v-if="withBack && canBack" @click.stop="back()" v-tooltip="$ts.goBack"><Fa :icon="faChevronLeft"/></button>
|
2020-10-17 11:12:00 +00:00
|
|
|
</transition>
|
|
|
|
<template v-if="info">
|
|
|
|
<div class="titleContainer">
|
2020-12-29 02:33:21 +00:00
|
|
|
<div class="title">
|
|
|
|
<Fa v-if="info.icon" :icon="info.icon" :key="info.icon" class="icon"/>
|
|
|
|
<MkAvatar v-else-if="info.avatar" class="avatar" :user="info.avatar" :disable-preview="true"/>
|
|
|
|
<span v-if="info.title" class="text">{{ info.title }}</span>
|
|
|
|
<MkUserName v-else-if="info.userName" :user="info.userName" :nowrap="false" class="text"/>
|
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
2021-04-10 04:38:24 +00:00
|
|
|
<div class="buttons">
|
|
|
|
<template v-if="info.actions && showActions">
|
|
|
|
<button v-for="action in info.actions" class="_button button" @click.stop="action.handler" v-tooltip="action.text"><Fa :icon="action.icon"/></button>
|
|
|
|
</template>
|
|
|
|
<button v-if="showMenu" class="_button button" @click.stop="menu"><Fa :icon="faEllipsisH"/></button>
|
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-04-10 03:40:50 +00:00
|
|
|
import { faChevronLeft, faCircle, faShareAlt, faEllipsisH } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { modalMenu } from '@client/os';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
info: {
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
withBack: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2021-02-14 13:26:07 +00:00
|
|
|
center: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
canBack: false,
|
2021-04-10 04:38:24 +00:00
|
|
|
showActions: false,
|
2020-10-17 11:12:00 +00:00
|
|
|
height: 0,
|
2021-04-10 03:40:50 +00:00
|
|
|
faChevronLeft, faCircle, faShareAlt, faEllipsisH,
|
2020-10-17 11:12:00 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2021-04-10 04:38:24 +00:00
|
|
|
computed: {
|
|
|
|
showMenu() {
|
|
|
|
if (this.info.actions != null && !this.showActions) return true;
|
|
|
|
if (this.info.menu != null) return true;
|
|
|
|
if (this.info.share != null) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
watch: {
|
2020-11-03 11:28:38 +00:00
|
|
|
$route: {
|
|
|
|
handler(to, from) {
|
|
|
|
this.canBack = (window.history.length > 0 && !['index'].includes(to.name));
|
|
|
|
},
|
|
|
|
immediate: true
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.height = this.$el.parentElement.offsetHeight + 'px';
|
2021-04-10 04:38:24 +00:00
|
|
|
this.showActions = this.$el.parentElement.offsetWidth >= 500;
|
2020-10-17 11:12:00 +00:00
|
|
|
new ResizeObserver((entries, observer) => {
|
|
|
|
this.height = this.$el.parentElement.offsetHeight + 'px';
|
2021-04-10 04:38:24 +00:00
|
|
|
this.showActions = this.$el.parentElement.offsetWidth >= 500;
|
2020-10-17 11:12:00 +00:00
|
|
|
}).observe(this.$el);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
back() {
|
|
|
|
if (this.canBack) this.$router.back();
|
|
|
|
},
|
2021-04-10 03:40:50 +00:00
|
|
|
|
|
|
|
share() {
|
|
|
|
navigator.share(this.info.share);
|
|
|
|
},
|
|
|
|
|
|
|
|
menu(ev) {
|
|
|
|
const menu = this.info.menu ? this.info.menu() : [];
|
|
|
|
if (this.info.share) {
|
|
|
|
if (menu.length > 0) menu.push(null);
|
|
|
|
menu.push({
|
|
|
|
text: this.$ts.share,
|
|
|
|
icon: faShareAlt,
|
|
|
|
action: this.share
|
|
|
|
});
|
|
|
|
}
|
|
|
|
modalMenu(menu, ev.currentTarget || ev.target);
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-11-28 03:15:22 +00:00
|
|
|
<style lang="scss" scoped>
|
2020-10-17 11:12:00 +00:00
|
|
|
.fdidabkb {
|
2021-02-14 13:26:07 +00:00
|
|
|
&.center {
|
|
|
|
text-align: center;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2021-04-10 03:40:50 +00:00
|
|
|
> .titleContainer {
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 04:38:24 +00:00
|
|
|
> .back {
|
2021-04-10 03:40:50 +00:00
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
top: 0;
|
2021-04-10 04:38:24 +00:00
|
|
|
left: 0;
|
2020-11-28 03:19:57 +00:00
|
|
|
height: var(--height);
|
|
|
|
width: var(--height);
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 04:38:24 +00:00
|
|
|
> .buttons {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
top: 0;
|
2020-10-17 11:12:00 +00:00
|
|
|
right: 0;
|
2021-04-10 04:38:24 +00:00
|
|
|
|
|
|
|
> .button {
|
|
|
|
height: var(--height);
|
|
|
|
width: var(--height);
|
|
|
|
}
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
> .titleContainer {
|
|
|
|
overflow: auto;
|
|
|
|
white-space: nowrap;
|
2021-04-10 03:40:50 +00:00
|
|
|
width: calc(100% - (var(--height) * 2));
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
> .title {
|
|
|
|
display: inline-block;
|
|
|
|
vertical-align: bottom;
|
|
|
|
white-space: nowrap;
|
2021-03-02 13:57:16 +00:00
|
|
|
overflow: hidden;
|
2020-10-17 11:12:00 +00:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
padding: 0 16px;
|
2020-11-07 03:31:23 +00:00
|
|
|
position: relative;
|
2021-04-10 03:40:50 +00:00
|
|
|
height: var(--height);
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
> .icon + .text {
|
|
|
|
margin-left: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
$size: 32px;
|
|
|
|
display: inline-block;
|
|
|
|
width: $size;
|
|
|
|
height: $size;
|
|
|
|
vertical-align: bottom;
|
2021-04-10 03:40:50 +00:00
|
|
|
margin: calc((var(--height) - #{$size}) / 2) 8px calc((var(--height) - #{$size}) / 2) 0;
|
|
|
|
pointer-events: none;
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|